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 :(
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
您也可以尝试通过禁用批处理模式来更改 go get 调用 ssh 的方式:
env GIT_SSH_COMMAND="ssh -o ControlMaster=no -o BatchMode=no" go get github.com/<YOUR_REPO_HERE>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.