返回顶部
首页 > 资讯 > 后端开发 > GO >GitHub / 私人存储库 / SSH:go get/go mod tidy 失败,而 git clone 正在工作
  • 448
分享到

GitHub / 私人存储库 / SSH:go get/go mod tidy 失败,而 git clone 正在工作

2024-04-05 00:04:21 448人浏览 八月长安
摘要

有志者,事竟成!如果你在学习golang,那么本文《GitHub / 私人存储库 / ssh:Go get/go mod tidy 失败,而 git clone 正在工作》,就很适合你!文章讲解的知

有志者,事竟成!如果你在学习golang,那么本文《GitHub / 私人存储库 / sshGo get/go mod tidy 失败,而 git clone 正在工作》,就很适合你!文章讲解的知识点主要包括,若是你对本文感兴趣,或者是想搞懂其中某个知识点,就请你继续往下看吧~

问题内容

我希望找到过去几天困扰我的问题的答案 - 我已经阅读了很多线程、帮助程序和出版物,但似乎没有找到解决方案。 我对 ssh 有点陌生。

问题如下: 使用 go getgo 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

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

我的环境:

  • win10 企业版
  • git 版本 - 2.31.1.windows.1
  • 我通常通过 tortoisegit 2.13.0.1 克隆
  • 在 cmd/powershell 中使用 ssh 客户端 - openssh_for_windows_8.9,手动安装

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://www.lsjlt.com/news/596837.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
  • 如何正确处理使用 Mux 的 Go 的可选查询参数?
    本篇文章主要是结合我之前面试的各种经历和实战开发中遇到的问题解决经验整理的,希望这篇《如何正确处理使用 Mux 的 Go 的可选查询参数?》对你有很大帮助!欢迎收藏,分享给更多的需要的朋友学习~问题...
    99+
    2026-06-09
  • 如何在golang中格式化txt?
    知识点掌握了,还需要不断练习才能熟练运用。下面编程网给大家带来一个Golang开发实战,手把手教大家学习《如何在golang中格式化txt?》,在实现功能的过程中也带大家重新温习相关知识点,温故而知...
    99+
    2026-06-09
  • 使用 golang 在 google admin sdk api 上获取 400 invalid_grant。有什么建议么?
    一分耕耘,一分收获!既然都打开这篇《使用 golang 在 google admin sdk api 上获取 400 invalid_grant。有什么建议么?》,就坚持看下去,学下去吧!本文主要会...
    99+
    2026-06-09
  • 我可以在应用程序引擎上部署 Golang 应用程序并在不修改代码的情况下读取/写入文件吗?
    在Golang实战开发的过程中,我们经常会遇到一些这样那样的问题,然后要卡好半天,等问题解决了才发现原来一些细节知识点还是没有掌握好。今天编程网就整理分享《我可以在应用程序引擎上部署 Golang ...
    99+
    2026-06-09
  • Sqlx 连接具有相同字段的表
    对于一个Golang开发者来说,牢固扎实的基础是十分重要的,编程网就来带大家一点点的掌握基础知识点。今天本篇文章带大家了解《Sqlx 连接具有相同字段的表》,主要介绍了,希望对大家的知识积累有所帮助...
    99+
    2026-06-09
  • 如何从 go 中的另一个包访问结构变量?
    各位小伙伴们,大家好呀!看看今天我又给各位带来了什么文章?本文标题是《如何从 go 中的另一个包访问结构变量?》,很明显是关于Golang的文章哈哈哈,其中内容主要会涉及到等等,如果能帮到你,觉得很...
    99+
    2026-06-09
  • 使用 kafka-go 在 Kafka 中计划创建消费者
    编程并不是一个机械性的工作,而是需要有思考,有创新的工作,语法是固定的,但解决问题的思路则是依靠人的思维,这就需要我们坚持学习和更新自己的知识。今天编程网就整理分享《使用 kafka-go 在 Ka...
    99+
    2026-06-09
  • 无法从 Golang 中的 Google userinfo API 响应访问电话号码(使用 golang.org/x/oauth2 和 Google People API)
    有志者,事竟成!如果你在学习Golang,那么本文《无法从 Golang 中的 Google userinfo API 响应访问电话号码(使用 golang.org/x/oauth2 和 Googl...
    99+
    2026-06-09
  • 如何使用 Gin-Gonic 在 Go 中读取蛇形 JSON 请求正文
    各位小伙伴们,大家好呀!看看今天我又给各位带来了什么文章?本文标题是《如何使用 Gin-Gonic 在 Go 中读取蛇形 JSON 请求正文》,很明显是关于Golang的文章哈哈哈,其中内容主要会涉...
    99+
    2026-06-09
  • 将带有指针值的interface{}类型传递给interface{}参数
    小伙伴们对Golang编程感兴趣吗?是否正在学习相关知识点?如果是,那么本文《将带有指针值的interface{}类型传递给interface{}参数》,就很适合你,本篇文章讲解的知识点主要包括。在...
    99+
    2026-06-09
  • 协会不处理测试条目
    今日不肯埋头,明日何以抬头!每日一句努力自己的话哈哈~哈喽,今天我将给大家带来一篇《协会不处理测试条目》,主要内容是讲解等等,感兴趣的朋友可以收藏或者有更好的建议在评论提出,我都会认真看的!大家一起...
    99+
    2026-06-09
  • 如何UT上传文件
    珍惜时间,勤奋学习!今天给大家带来《如何UT上传文件》,正文内容主要涉及到等等,如果你正在学习Golang,或者是对Golang有疑问,欢迎大家关注我!后面我会持续更新相关内容的,希望都能帮到正在学...
    99+
    2026-06-09
  • 为什么 go 程序将输出打印到终端屏幕而不是 /dev/stderr?
    各位小伙伴们,大家好呀!看看今天我又给各位带来了什么文章?本文标题是《为什么 go 程序将输出打印到终端屏幕而不是 /dev/stderr?》,很明显是关于Golang的文章哈哈哈,其中内容主要会涉...
    99+
    2026-06-09
  • 如何在 GO 中将“_Ctype_int”更改为“int”?
    小伙伴们对Golang编程感兴趣吗?是否正在学习相关知识点?如果是,那么本文《如何在 GO 中将“_Ctype_int”更改为“int”?》,就很适合你,本篇文章讲解的知识点主要包括。在之后的文章中...
    99+
    2026-06-09
  • 为什么我的自定义错误类型会导致特定模式的错误?
    有志者,事竟成!如果你在学习Golang,那么本文《为什么我的自定义错误类型会导致特定模式的错误?》,就很适合你!文章讲解的知识点主要包括,若是你对本文感兴趣,或者是想搞懂其中某个知识点,就请你继续...
    99+
    2026-06-09
  • 如何从空的 interface{} 类型访问 JSON 数据中的字段?
    大家好,我们又见面了啊~本文《如何从空的 interface{} 类型访问 JSON 数据中的字段?》的内容中将会涉及到等等。如果你正在学习Golang相关知识,欢迎关注我,以后会给大家带来更多Go...
    99+
    2026-06-09
  • 如何在Golang中为Azure SDK指定x509证书
    你在学习Golang相关的知识吗?本文《如何在Golang中为Azure SDK指定x509证书》,主要介绍的内容就涉及到,如果你想提升自己的开发能力,就不要错过这篇文章,大家要知道编程理论基础和实...
    99+
    2026-06-09
  • etcd 事务中的原子计数器增量
    知识点掌握了,还需要不断练习才能熟练运用。下面编程网给大家带来一个Golang开发实战,手把手教大家学习《etcd 事务中的原子计数器增量》,在实现功能的过程中也带大家重新温习相关知识点,温故而知新...
    99+
    2026-06-09
  • 将字段添加到 MongoDB 内部对象
    知识点掌握了,还需要不断练习才能熟练运用。下面编程网给大家带来一个Golang开发实战,手把手教大家学习《将字段添加到 MongoDB 内部对象》,在实现功能的过程中也带大家重新温习相关知识点,温故...
    99+
    2026-06-09
  • 为什么 rows.Next() 取决于数据库响应率?
    亲爱的编程学习爱好者,如果你点开了这篇文章,说明你对《为什么 rows.Next() 取决于数据库响应率?》很感兴趣。本篇文章就来给大家详细解析一下,主要介绍一下,希望所有认真读完的童鞋们,都有实质...
    99+
    2026-06-09
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作