当前位置:首页 > 文章列表 > Golang > Go问答 > GitHub / 私人存储库 / SSH:go get/go mod tidy 失败,而 git clone 正在工作

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

来源:stackoverflow 2024-04-04 20:36:42 0浏览 收藏

有志者,事竟成!如果你在学习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..com///tests/functional/resources tested by
    example.com/hello/projects/src/git..com///tests/functional/resources.test imports
    git..com///tests/functional/resources/vm_specific: module git..com///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\\/.ssh/known_hosts'
    debug3: expanded userknownhostsfile '~/.ssh/known_hosts2' -> 'c:\\users\\/.ssh/known_hosts2'
    debug2: resolving "git..com" port 
    debug3: resolve_host: lookup git..com:
    debug3: ssh_connect_direct: entering
    debug1: connecting to git..com [10.xxx.x.xx] 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..com: as 'git'
    ...
    debug1: authentications that can continue: publickey
    ...
    debug3: send packet: type 50
    debug3: receive packet: type 52
    authenticated to git..com ([10.xxx.x.xx]:) using "publickey".
    ...
    debug1: sending command: git-upload-pack '/scm//.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..com:

debug3: send packet: type 50
    debug3: receive packet: type 52
    debug1: authentication succeeded (publickey).
    authenticated to git..com ([10.xxx.x.xx]:).
    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\\appdata\local\go-build
    set goenv=c:\users\\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=*..com;git..com/users/
    set gonosumdb=*..com;git..com/users/
    set goos=windows
    set gopath=c:\program files\go
    set goprivate=*..com;git..com/users/
    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..com
           serveraliveinterval 600
           tcpkeepalive yes
           ipqos throughput
           addkeystoagent yes
           hostname git..com
           port 
           user 
           preferredauthentications publickey
           identityfile c:\users\\.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..com\\>go get git..com//go-service/log
     go: module git..com//go-service/log: git ls-remote -q origin in c:\go\projects\pkg\mod\cache\vcs\d0d607237eeba0d1c9d5ce996ed36c0f3746b2c8f94b538ace2d3f2a9476839e: exit status 128:
         c:\\users\\/.ssh/config: line 15: bad configuration option: allowpkcs12keystoreautoopen
         c:\\users\\/.ssh/config: terminating, 1 bad configuration options

git 配置:

  • 全球:

    [user]
         name = 
         email = @.com
    
     [url "ssh://git@git..com:/"]
         insteadof = https://git..com
  • 系统:

    [url "ssh://git@git..com:/"]
         insteadof = https://git..com/

git远程-v:

origin  ssh://git@git..com:/~/.git (fetch)
    origin  ssh://git@git..com:/~/.git (push)
  • 与我用于克隆的相同,

存储库配置:

[remote "origin"]
        url = ssh://git@git..com:/~/.git
        fetch = +refs/heads/*:refs/remotes/origin/*

我尝试了 ssh:// 和 git@git...但没有帮助。

模块配置(自动设置),但是:

[remote "origin"]
        url = https://git..com/scm//.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的相关知识,请关注golang学习网公众号!

版本声明
本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
东风汽车新能源“对赌”激励机制见成效,猛士917销售势头强劲东风汽车新能源“对赌”激励机制见成效,猛士917销售势头强劲
上一篇
东风汽车新能源“对赌”激励机制见成效,猛士917销售势头强劲
Galaxy Z Fold5:突破折叠屏技术 为用户带来绚丽视觉震撼
下一篇
Galaxy Z Fold5:突破折叠屏技术 为用户带来绚丽视觉震撼
查看更多
最新文章
查看更多
课程推荐
  • 前端进阶之JavaScript设计模式
    前端进阶之JavaScript设计模式
    设计模式是开发人员在软件开发过程中面临一般问题时的解决方案,代表了最佳的实践。本课程的主打内容包括JS常见设计模式以及具体应用场景,打造一站式知识长龙服务,适合有JS基础的同学学习。
    543次学习
  • GO语言核心编程课程
    GO语言核心编程课程
    本课程采用真实案例,全面具体可落地,从理论到实践,一步一步将GO核心编程技术、编程思想、底层实现融会贯通,使学习者贴近时代脉搏,做IT互联网时代的弄潮儿。
    516次学习
  • 简单聊聊mysql8与网络通信
    简单聊聊mysql8与网络通信
    如有问题加微信:Le-studyg;在课程中,我们将首先介绍MySQL8的新特性,包括性能优化、安全增强、新数据类型等,帮助学生快速熟悉MySQL8的最新功能。接着,我们将深入解析MySQL的网络通信机制,包括协议、连接管理、数据传输等,让
    500次学习
  • JavaScript正则表达式基础与实战
    JavaScript正则表达式基础与实战
    在任何一门编程语言中,正则表达式,都是一项重要的知识,它提供了高效的字符串匹配与捕获机制,可以极大的简化程序设计。
    487次学习
  • 从零制作响应式网站—Grid布局
    从零制作响应式网站—Grid布局
    本系列教程将展示从零制作一个假想的网络科技公司官网,分为导航,轮播,关于我们,成功案例,服务流程,团队介绍,数据部分,公司动态,底部信息等内容区块。网站整体采用CSSGrid布局,支持响应式,有流畅过渡和展现动画。
    485次学习
查看更多
AI推荐
  • PubMedQA数据集详解:生物医学问答基准、功能与应用指南
    PubMedQA
    深入了解PubMedQA生物医学问答数据集,涵盖其核心功能、使用方法及在临床决策、药物研发等场景的应用,助力提升NLP模型性能。
    298次使用
  • H2O EvalGPT:开源LLM大模型评估与排行榜工具
    H2O EvalGPT
    H2O EvalGPT是H2O.ai推出的开源LLM评估平台,提供详细的大模型性能排行榜、行业特定基准测试及A/B测试功能,助您快速选择最适合项目的高性能大语言模型。
    352次使用
  • LMArena是什么?伯克利AI模型评估平台使用指南与功能解析
    LMArena
    LMArena是加州大学伯克利分校推出的AI模型匿名评测平台。通过盲测投票机制,用户可对比不同大模型回答并生成实时排行榜,助力开发者优化模型及用户选择最佳AI工具。
    353次使用
  • 斯坦福HELM:大语言模型Holistic Evaluation整体评估框架详解
    HELM
    深入了解斯坦福推出的HELM(Holistic Evaluation of Language Models)大模型评测体系。本文解析其核心功能、安装配置步骤及应用场景,涵盖准确性、公平性、鲁棒性等多维度指标,助力开发者全面优化语言模型性能。
    318次使用
  • MMBench详解:多模态大模型基准测试、功能特点与使用指南
    MMBench
    MMBench是由上海人工智能实验室等机构联合推出的多模态基准测试平台,提供细粒度能力评估、大规模数据集及VLMEvalKit工具。本文详细介绍其核心功能、安装使用方法及应用场景,助力开发者全面评估多模态模型性能。
    137次使用
微信登录更方便
  • 密码登录
  • 注册账号
登录即同意 用户协议 和 隐私政策
返回登录
  • 重置密码