go - 去获取私有 bitbucket repo,禁止 403
问题描述
在执行时
go get bitbucket.org/../..
我收到这个错误
yash.jain projectname % go get bitbucket.org/../..
go: bitbucket.org/../..
https://api.bitbucket.org/2.0/repositories/../..?fields=scm: 403 Forbidden
go: error loading module requirements
我试过的
设置 ssh 密钥(按预期工作,通过推拉代码进行测试)
将 go env 变量设置为:
GOPRIVATE="" GOPROXY="direct" GOSUMDB="off"
.gitconfig 看起来像这样
[url "git@bitbucket.org:"] insteadOf = https://bitbucket.org/ [user] email = yash.jain@company.in name = yashjain
向 ssh-agent 添加了密钥
ssh-add -l ssh-add -k
.ssh/config 文件看起来像这样
Host bitbucket.org HostName bitbucket.org User git IdentityFile ~/.ssh/id_rsa UseKeychain yes StrictHostKeyChecking no
不过,我得到了同样的错误。如果我做错了什么,请告诉我。
解决方案
这些是我试图使其工作的步骤。
- 设置 SSH 密钥并连接到 bitbucket。我通过 bitbucket 使用 sourcetree gui 来连接使用
ssh
. - 设置
GOPRIVATE=bitbucket.org/<orgname>/*
*
是允许组织的所有回购。
在这两个步骤之后,我可以导入包。
注意:Sourcetree 仅适用于 Mac 和 Windows。
使用命令行:对于 Linux/Mac/Windows:
git config --global url."git@bitbucket.org:".insteadOf "https://bitbucket.org/"
- 设置
GOPRIVATE=bitbucket.org/<orgname>/*