【问题标题】:How do I use go get with a private github enterprise server?如何在私有 github 企业服务器上使用 go get?
【发布时间】:2018-01-24 03:01:22
【问题描述】:

我们通过 VPN 使用 github 企业服务器。

如果我输入:

go get privateserver.com/path/to/myproject.git

我得到这个结果:

package privateserver.com/path/to/myproject.git: cannot download, privateserver.com/path/to/myproject uses insecure protocol

或者删除我得到的 .git 后缀:

package privateserver.com/path/to/myproject: unrecognized import path "privateserver.com/path/to/myproject" (parse https://privateserver.com/path/to/myproject?go-get=1: no go-import meta tags ())

Google 搜索似乎有很多类似的问题,但没有找到真正有效的答案。

我真正想要的是 docker 构建的自动化。 在我的 docker 文件中,我需要 go get。但我无法将凭据存储在 docker 文件中。

注意:--insecure 不起作用。见问题底部。


刚刚尝试使用 -insecure -v 选项进行获取。 我得到以下输出:

matthewh@xen:~/go/src/$ go get -insecure -v privateserver.com/path/to/myproject.git
# cd .; git ls-remote git://privateserver.com/path/to/myproject
fatal: remote error: 
  GitHub private mode is enabled. Git protocol is disabled. Use authenticated http or ssh access instead.
# cd .; git ls-remote https://privateserver.com/path/to/myproject
fatal: could not read Username for 'https://privateserver.com': terminal prompts disabled
# cd .; git ls-remote http://privateserver.com/path/to/myproject
fatal: could not read Username for 'https://privateserver.com': terminal prompts disabled
# cd .; git ls-remote git+ssh://privateserver.com/path/to/myproject
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
# cd .; git ls-remote ssh://privateserver.com/path/to/myproject
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
privateserver.com/path/to/myproject.git (download)
# cd .; git clone privateserver.com/path/to/myproject /home/matthewh/go/src/privateserver.com/path/to/myproject.git
fatal: repository 'privateserver.com/path/to/myproject' does not exist
package privateserver.com/path/to/myproject.git: exit status 128

【问题讨论】:

  • 设置 GitHub 私有 (ssh) 密钥使私有存储库的事情变得更加简单。

标签: go github-enterprise


【解决方案1】:

get 命令通过-insecure 标志支持使用http,如下所示:

go get -insecure privateserver.com/path/to/myproject.git

默认为安全 HTTPS,以防止中间人攻击,如 Git Issue 中所述。

【讨论】:

  • 如果我这样做,我会收到“存储库不存在错误。
  • 刚刚查看了您的个人资料。你是米尔顿·巴克斯特吗?
  • 我确实是。你是@Matt 某人吗?您是否尝试过不使用 .git 后缀。我在这里只用/myproject 尝试了一个小测试
  • 哈哈。米尔顿,这里有一个提示。彼得不是我爸爸,马来西亚很有趣。必须赶上一些时间。私有 github 服务器上似乎需要 git 后缀。
猜你喜欢
  • 2022-12-20
  • 1970-01-01
  • 2022-08-17
  • 2016-05-26
  • 1970-01-01
  • 2022-11-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多