[英]How to `go get` private repos using SSH key auth with password
I usually set a passphrase in my ssh keys so that, in case of it gets compromised, I might get some time to rotate to a new one.我通常在我的 ssh 密钥中设置一个密码,以便万一它受到威胁,我可能有时间轮换到一个新的。
However, when working with go modules, I noticed that when executing a go get
and making use of keys with passphrase, I get the error below但是,在使用 go 模块时,我注意到在执行
go get
并使用带密码的密钥时,出现以下错误
git@github.com: Permission denied (publickey).
git@github.com:权限被拒绝(公钥)。
Is there any way to be prompted for this password when resolving dependencies in Go?在 Go 中解析依赖项时,有没有办法提示输入这个密码?
For now, I removed the password :(现在,我删除了密码:(
use an agent.使用代理。 On Linux or Macos the process is
在 Linux 或 Macos 上,过程是
ssh-agent bash
this first step starts a shell with ssh-agent第一步是使用 ssh-agent 启动一个 shell
ssh-add ~/.ssh/id_rsa
the second step adds a key to the agent, ~/.ssh/id_rsa is the path to the key.第二步给agent添加一个key,~/.ssh/id_rsa是key的路径。 After this step it will ask once for the passphrase
在这一步之后,它会要求输入一次密码
Once you've done these things any command in the new shell will use the keys loaded with ssh-add完成这些操作后,新 shell 中的任何命令都将使用通过 ssh-add 加载的密钥
您也可以尝试通过禁用批处理模式来更改 go get 调用 ssh 的方式:
env GIT_SSH_COMMAND="ssh -o ControlMaster=no -o BatchMode=no" go get github.com/<YOUR_REPO_HERE>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.