有志者,事竟成!如果你在学习golang,那么本文《GitHub / 私人存储库 / ssh:Go get/go mod tidy 失败,而 git clone 正在工作》,就很适合你!文章讲解的知
有志者,事竟成!如果你在学习golang,那么本文《GitHub / 私人存储库 / ssh:Go get/go mod tidy 失败,而 git clone 正在工作》,就很适合你!文章讲解的知识点主要包括,若是你对本文感兴趣,或者是想搞懂其中某个知识点,就请你继续往下看吧~
问题内容我希望找到过去几天困扰我的问题的答案 - 我已经阅读了很多线程、帮助程序和出版物,但似乎没有找到解决方案。 我对 ssh 有点陌生。
问题如下:
使用 go get
或 go mod tidy
命令时,我无法获取/安装/刷新属于我的项目的模块,
虽然在任何终端中通过 ssh 或通过 tortoisegit 运行同一存储库的 git clone
都工作正常,
即我可以克隆,但无法构建。
获取模块失败的方式如下(个人数据混淆):
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 设置为默认值)的最后几行 git@git.<orgname>.com
:
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
因此工作正常,这已经让我发疯了。
我已经有大部分模块无法在远程私有仓库中检查,这更疯狂。
我不喜欢这部分,这很可能意味着我的证书有问题 -
使用 git..com ([10.xxx.x.xx]:) 进行身份验证 “公钥”。
这部分,因为 aix 上的 openssh 在启用 efs 时默认请求 pkcs12 支持,非 aix 系统可能会拒绝这些 pkcs12 请求。
debug2:通道 0:obuf_empty 延迟 efd 6/(106) debug2:通道0:将106写入efd 6
请参阅下面我的配置中的更改。
我的环境:
go env:(个人数据已混淆)
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 配置:
# 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
中没有完全未知的条目,并且正在使用根据证书时间戳判断的正确条目。
我发现可以通过将 allowpkcs12keystoreautoopen
设置为 no
来禁用 pkcs12 请求,但它被标记为错误选项 -
c:\go\projects\src\git.<orgname>.com\<reponame>\<subreponame>>go get git.<orgname>.com/<name>/go-service/log
go: module git.<orgname>.com/<name>/go-service/log: git ls-remote -q origin in c:\go\projects\pkg\mod\cache\vcs\d0d607237eeba0d1c9d5ce996ed36c0f3746b2c8f94b538ace2d3f2a9476839e: exit status 128:
c:\\users\\<username>/.ssh/config: line 15: bad configuration option: allowpkcs12keystoreautoopen
c:\\users\\<username>/.ssh/config: terminating, 1 bad configuration options
git 配置:
全球:
[user]
name = <username>
email = <usrname>@<orgname>.com
[url "ssh://git@git.<orgname>.com:<port>/"]
insteadof = Https://git.<orgname>.com
系统:
[url "ssh://git@git.<orgname>.com:<port>/"]
insteadof = https://git.<orgname>.com/
git远程-v:
origin ssh://git@git.<orgname>.com:<port>/~<username>/<subreponame>.git (fetch)
origin ssh://git@git.<orgname>.com:<port>/~<username>/<subreponame>.git (push)
存储库配置:
[remote "origin"]
url = ssh://git@git.<orgname>.com:<port>/~<username>/<subreponame>.git
fetch = +refs/heads/*:refs/remotes/origin/*
我尝试了 ssh:// 和 git@git...但没有帮助。
模块配置(自动设置),但是:
[remote "origin"]
url = https://git.<orgname>.com/scm/<reponame>/<subreponame>.git
fetch = +refs/heads/*:refs/remotes/origin/*
我现在没有想法。
我建议不要将 go get
与私有存储库一起使用。此命令将存储库缓存在 pkg.go.dev 上,从而将它们公开给全世界。我很尴尬地发现我们的私人开发项目在那里公开发布。
我在文件系统中手动部署私有依赖项,并使用替换在 go.mod
中指定依赖项:
require your.server/your/package 1.2.3
replace your.server/your/package 1.2.3 => /path/to/local/your/package
本篇关于《GitHub / 私人存储库 / SSH:go get/go mod tidy 失败,而 git clone 正在工作》的介绍就到此结束啦,但是学无止境,想要了解学习更多关于Golang的相关知识,请关注编程网公众号!
--结束END--
本文标题: GitHub / 私人存储库 / SSH:go get/go mod tidy 失败,而 git clone 正在工作
本文链接: https://lsjlt.com/news/596837.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-04-05
2024-04-05
2024-04-05
2024-04-04
2024-04-05
2024-04-05
2024-04-05
2024-04-05
2024-04-04
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0