首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >GitHub /私有存储库/ SSH: git克隆运行时git/ go mod清理失败

GitHub /私有存储库/ SSH: git克隆运行时git/ go mod清理失败
EN

Stack Overflow用户
提问于 2022-08-25 17:46:56
回答 2查看 361关注 0票数 1

我希望找到过去几天困扰我的问题的答案--我读了很多帖子、助手和出版物,但似乎找不到解决办法。我对SSH有点陌生。

问题如下:在使用go getgo mod tidy命令时,我无法获得/安装/刷新属于我的项目的模块,而在任何终端或TortoiseGit中,通过SSH进行相同回购的git clone都可以正常工作,也就是说,我可以克隆,但不能构建。

获取模块失败的方式如下(个人数据混淆):

代码语言:javascript
运行
复制
    example.com/hello/PROJECTS/src/git.<orgname>.com/<reponame>/<subreponame>/tests/functional/resources tested by
    example.com/hello/PROJECTS/src/git.<orgname>.com/<reponame>/<subreponame>/tests/functional/resources.test imports
    git.<orgname>.com/<reponame>/<subreponame>/tests/functional/resources/vm_specific: module git.<orgname>.com/<reponame>/<subreponame>/tests/functional/resources/vm_specific: git ls-remote -q origin in C:\GO\PROJECTS\pkg\mod\cache\vcs\a5d519aeafc0ac08e2b20d7c8a6a8b2cea11cda88cb058cf2ebcc079d07b260a: exit status 128:
    debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> 'C:\\Users\\<username>/.ssh/known_hosts'
    debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> 'C:\\Users\\<username>/.ssh/known_hosts2'
    debug2: resolving "git.<orgname>.com" port <port>
    debug3: resolve_host: lookup git.<orgname>.com:<port>
    debug3: ssh_connect_direct: entering
    debug1: Connecting to git.<orgname>.com [10.XXX.X.XX] port <port>.
    debug1: Connection established.
    ...
    debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.9
    debug1: Remote protocol version 2.0, remote software version APACHE-SSHD-2.4.0
    debug1: compat_banner: no match: APACHE-SSHD-2.4.0
    debug2: fd 3 setting O_NONBLOCK
    debug1: Authenticating to git.<orgname>.com:<port> as 'git'
    ...
    debug1: Authentications that can continue: publickey
    ...
    debug3: send packet: type 50
    debug3: receive packet: type 52
    Authenticated to git.<orgname>.com ([10.XXX.X.XX]:<port>) using "publickey".
    ...
    debug1: Sending command: git-upload-pack '/scm/<reponame>/<subreponame>.git'
    debug2: channel 0: request exec confirm 1
    debug3: send packet: type 98
    debug2: channel_input_open_confirmation: channel 0: callback done
    debug2: channel 0: open confirm rwindow 2097152 rmax 32768
    debug3: receive packet: type 99
    debug2: channel_input_status_confirm: type 99 id 0
    debug2: exec request accepted on channel 0
    debug2: channel 0: rcvd ext data 106
    debug3: receive packet: type 96
    debug2: channel 0: rcvd eof
    debug2: channel 0: output open -> drain
    debug3: receive packet: type 98
    debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
    debug3: receive packet: type 97
    debug2: channel 0: rcvd close
    debug2: chan_shutdown_read: channel 0: (i0 o1 sock -1 wfd 4 efd 6 [write])
    debug2: channel 0: input open -> closed
    debug3: channel 0: will not send data after close
    debug2: channel 0: obuf_empty delayed efd 6/(106)
    debug2: channel 0: written 106 to efd 6
    Repository not found
    The requested repository does not exist, or you do not have permission to access it.
    debug3: channel 0: will not send data after close
    debug2: channel 0: obuf empty
    debug2: chan_shutdown_write: channel 0: (i3 o1 sock -1 wfd 5 efd 6 [write])
    debug2: channel 0: output drain -> closed
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.
    debug2: channel 0: almost dead
    debug2: channel 0: gc: notify user
    debug2: channel 0: gc: user detached
    debug2: channel 0: send close
    debug3: send packet: type 97
    debug2: channel 0: is dead
    debug2: channel 0: garbage collecting
    debug1: channel 0: free: client-session, nchannels 1
    debug3: channel 0: status: The following connections are open:
      #0 client-session (t4 r0 i3/0 o3/0 e[write]/0 fd -1/-1/6 sock -1 cc -1 io 0x00/0x08)

    debug3: send packet: type 1
    Transferred: sent 3268, received 2200 bytes, in 0.2 seconds
    Bytes per second: sent 15169.6, received 10212.1
    debug1: Exit status 1

如果需要更完整的日志,我可以把它上传到某个地方。

最后一行ssh -T(vvv set as default) git@git.<orgname>.com

代码语言:javascript
运行
复制
    debug3: send packet: type 50
    debug3: receive packet: type 52
    debug1: Authentication succeeded (publickey).
    Authenticated to git.<orgname>.com ([10.XXX.X.XX]:<port>).
    debug1: channel 0: new [client-session]
    debug3: ssh_session2_open: channel_new: 0
    debug2: channel 0: send open
    debug3: send packet: type 90
    debug1: Entering interactive session.
    debug1: pledge: filesystem full
    debug3: receive packet: type 91
    debug2: channel_input_open_confirmation: channel 0: callback start
    debug2: fd 3 setting TCP_NODELAY
    debug3: set_sock_tos: set socket 3 IP_TOS 0x08
    debug2: client_session2_setup: id 0
    debug2: channel 0: request shell confirm 1
    debug3: send packet: type 98
    debug2: channel_input_open_confirmation: channel 0: callback done
    debug2: channel 0: open confirm rwindow 2097152 rmax 32768
    debug3: receive packet: type 100
    debug2: channel_input_status_confirm: type 100 id 0
    shell request failed on channel 0

我使用从OpenSSH的ssh-keygen生成的密钥派生的公钥,它是新生成的,并添加到我的Git配置文件中。因此,git clone工作得很好,这已经让我发疯了。我已经有大部分模块无法在远程私有回购中进行检查,这甚至更疯狂。

我不喜欢这部分,这很可能意味着我的证书有问题-

使用"publickey“对git..com (10.XXX.X.XX:)进行身份验证。

而这部分,作为OpenSSH on AIX requests PKCS12 support by default when EFS is enabled and non-AIX systems may reject these PKCS12 requests.

debug2: channel 0: obuf\_empty delayed efd 6/(106) debug2: channel 0: written 106 to efd 6

请参阅下面配置中的更改。

我的环境:

Enterprise

  • Git
  • Win10 version - 2.31.1.windows.1
  • I通常通过TortoiseGit 2.13.0.1
  • SSH客户端克隆CMD/Powershell - OpenSSH_for_Windows_8.9,手动安装

go env: (个人数据混淆)

代码语言:javascript
运行
复制
    set GO111MODULE=
    set GOARCH=amd64
    set GOBIN=
    set GOCACHE=C:\Users\<username>\AppData\Local\go-build
    set GOENV=C:\Users\<username>\AppData\Roaming\go\env
    set GOEXE=.exe
    set GOEXPERIMENT=
    set GOFLAGS=
    set GOHOSTARCH=amd64
    set GOHOSTOS=windows
    set GOINSECURE=
    set GOMODCACHE=C:\Program Files\Go\pkg\mod
    set GONOPROXY=*.<orgname>.com;git.<orgname>.com/users/<username>
    set GONOSUMDB=*.<orgname>.com;git.<orgname>.com/users/<username>
    set GOOS=windows
    set GOPATH=C:\Program Files\Go
    set GOPRIVATE=*.<orgname>.com;git.<orgname>.com/users/<username>
    set GOPROXY=https://proxy.golang.org,direct
    set GOROOT=C:\Program Files\Go
    set GOSUMDB=sum.golang.org
    set GOTMPDIR=
    set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
    set GOVCS=
    set GOVERSION=go1.18.3
    set GCCGO=gccgo
    set GOAMD64=v1
    set AR=ar
    set CC=gcc
    set CXX=g++
    set CGO_ENABLED=1
    set GOMOD=NUL
    set GOWORK=
    set CGO_CFLAGS=-g -O2
    set CGO_CPPFLAGS=
    set CGO_CXXFLAGS=-g -O2
    set CGO_FFLAGS=-g -O2
    set CGO_LDFLAGS=-g -O2
    set PKG_CONFIG=pkg-config
    set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\USER~1.NAM\AppData\Local\Temp\go-build1143995380=/tmp/go-build -gno-record-gcc-switches

我的SSH配置:

代码语言:javascript
运行
复制
    # GITHUB FOR SRC
        Host git.<orgname>.com
           ServerAliveInterval 600
           TCPKeepAlive yes
           IPQoS throughput
           AddKeysToAgent yes
           HostName git.<orgname>.com
           Port <port>
           User <username>
           PreferredAuthentications publickey
           IdentityFile C:\Users\<username>\.ssh\git_rsa
           #IdentityFile ~/.ssh/git_rsa
           PubkeyAcceptedKeyTypes +ssh-rsa
           #ForwardAgent no
           #AllowPKCS12KeystoreAutoOpen no
           LogLevel DEBUG3

  • 证书以前添加到代理中,但我在这里指定了它以确保,并且根据日志.

,正确的证书似乎被用作身份验证。

  • 它没有密码。

  • 我的known-hosts中没有完全未知的条目,并且使用了由证书时间戳判断的正确条目.

  • I发现PKCS12请求可以被AllowPKCS12KeystoreAutoOpen设置为no禁用,但是它被标记为一个糟糕的选项-

C:\GO\PROJECTS\pkg\mod\cache\vcs\d0d607237eeba0d1c9d5ce996ed36c0f3746b2c8f94b538ace2d3f2a9476839e:退出状态128: C:\ C:\GO\PROJECTS\src\git..com\\>go \/..ssh/config:第15行:坏配置选项: allowpkcs12keystoreautoopen C:\Users\/..ssh/C:\GO\PROJECTS\src\git..com\\>go:终止,一个错误的配置选项

GIT吐露:

  • 全局:

用户名= @.com url“ssh://git@git.com:/”insteadOf =@.com

  • 系统:

url“ssh://git@git.com:/”insteadOf =insteadOf

git远程-v:

代码语言:javascript
运行
复制
    origin  ssh://git@git.<orgname>.com:<port>/~<username>/<subreponame>.git (fetch)
    origin  ssh://git@git.<orgname>.com:<port>/~<username>/<subreponame>.git (push)

  • 与我用于克隆的

相同

回购配置:

代码语言:javascript
运行
复制
    [remote "origin"]
        url = ssh://git@git.<orgname>.com:<port>/~<username>/<subreponame>.git
        fetch = +refs/heads/*:refs/remotes/origin/*

我试过//和git@git..。但这没什么用。

然而,模块配置(自动设置):

代码语言:javascript
运行
复制
    [remote "origin"]
        url = https://git.<orgname>.com/scm/<reponame>/<subreponame>.git
        fetch = +refs/heads/*:refs/remotes/origin/*

我现在没有主意了。

EN

回答 2

Stack Overflow用户

发布于 2022-08-25 18:50:15

我建议不要在私有存储库中使用go get。此命令在pkg.go.dev缓存存储库,从而将它们公开给世界。我很尴尬地发现,我们的私人发展公开发表在那里。

我手动地在文件系统中部署我的私有依赖项,并使用替换指定go.mod中的依赖项:

代码语言:javascript
运行
复制
require your.server/your/package 1.2.3

replace your.server/your/package 1.2.3 => /path/to/local/your/package
票数 0
EN

Stack Overflow用户

发布于 2022-09-08 17:36:17

这是存储库的一个问题--它实际上不是用来处理依赖关系的,也不是用来处理模块和模块相关请求的。但是至少我已经学到了很多关于SSH和GIT交互的知识。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73491769

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档