英文:
How to `go get` private repos using SSH key auth with password
问题
我通常会在我的ssh密钥中设置一个密码短语,这样,如果密钥被泄露,我可以有一些时间来更换新的密钥。
然而,当我在使用go模块时,我注意到当执行go get
并使用带有密码短语的密钥时,会出现以下错误:
git@github.com: Permission denied (publickey)。
在Go中解析依赖项时,有没有办法提示输入密码?
目前,我已经移除了密码。
英文:
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.
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
> git@github.com: Permission denied (publickey).
Is there any way to be prompted for this password when resolving dependencies in Go?
For now, I removed the password
答案1
得分: 11
使用代理。在Linux或MacOS上,该过程是:
ssh-agent bash
这一步首先启动一个带有ssh-agent的shell。
ssh-add ~/.ssh/id_rsa
第二步将一个密钥添加到代理中,~/.ssh/id_rsa是密钥的路径。在这一步之后,它会要求输入一次密码短语。
完成这些步骤后,新shell中的任何命令都将使用通过ssh-add加载的密钥。
英文:
use an agent. On Linux or Macos the process is
ssh-agent bash
this first step starts a shell with ssh-agent
ssh-add ~/.ssh/id_rsa
the second step adds a key to the agent, ~/.ssh/id_rsa is the path to the 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
答案2
得分: 0
你也可以尝试更改go get调用ssh的方式,通过禁用批处理模式:
env GIT_SSH_COMMAND="ssh -o ControlMaster=no -o BatchMode=no" go get github.com/<YOUR_REPO_HERE>
英文:
You may also try to change the way go get invokes ssh, by disabling batch mode:
env GIT_SSH_COMMAND="ssh -o ControlMaster=no -o BatchMode=no" go get github.com/<YOUR_REPO_HERE>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论