当尝试通过 SSH 连接到 GitHub.com 在 Linux 计算机上时,你可能会在终端中看到以下消息
$ ssh -vT [email protected]
> ...
> Agent admitted failure to sign using the key.
> debug1: No more authentication methods to try.
> Permission denied (publickey).
有关更多详细信息,请参阅 Canonical Launchpad 上的此问题报告。
解决方案
你应该能够通过使用 ssh-add
将你的密钥加载到 SSH 代理来修复此错误
# start the ssh-agent in the background
$ eval "$(ssh-agent -s)"
> Agent pid 59566
$ ssh-add
> Enter passphrase for /home/YOU/.ssh/id_rsa: [tippy tap]
> Identity added: /home/YOU/.ssh/id_rsa (/home/YOU/.ssh/id_rsa)
如果你的密钥没有默认文件名(/.ssh/id_rsa
),你将不得不将该路径传递给 ssh-add
# start the ssh-agent in the background
$ eval "$(ssh-agent -s)"
> Agent pid 59566
$ ssh-add ~/.ssh/my_other_key
> Enter passphrase for /home/YOU/.ssh/my_other_key: [tappity tap tap]
> Identity added: /home/YOU/.ssh/my_other_key (/home/YOU/.ssh/my_other_key)