$ ssh -T -v git@github.com_在本地用ssh连接github出错_git@github.com: Permission denied (publickey).
$ ssh -T -v git@github.com报错:
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/eveline/.ssh/id_rsa
debug1: Trying private key: /Users/eveline/.ssh/id_dsa
debug1: Trying private key: /Users/eveline/.ssh/id_ecdsa
debug1: Trying private key: /Users/eveline/.ssh/id_ed25519
debug1: No more authentication methods to try.
git@github.com: Permission denied (publickey).
Troubleshooting(macOS系统)
看了很多博客和官方文档,我的解决方法如下:
先查看一下配置信息
$ ssh-add -l
The agent has no identities.
如果是这样,就是没有添加成功私人密钥,虽然已经生成了并且上传到了GitHub的ssh
$ ssh-add ~/.ssh/id_rsa #这个id_rsa应是你命名的私人密钥默认名,这里显示为没有此文件。我在生成时命名为了Jack_key
/Users/eveline/.ssh/id_rsa: No such file or directory
搞清楚了,开始行动
找到你生成的密钥文件路径,执行下面命令:
$ ssh-add path/to/your/ssh-key
Identity added: /Users/eveline/.ssh/Jack_key (/Users/eveline/.ssh/Jack_key)
好了,查看一下
$ ssh-add -l
2048 SHA256:Dd02IHmxxxxx...xxxxxxxxxFPsHkGxiVh48m0qI /Users/eveline/.ssh/Jack_key (RSA)
如此,则配置成功!
永久性添加密钥方法(仅Mac用户):
$ ssh-add -K path/to/your/ssh-key
该方法摘自https://segmentfault.com/q/1010000000835302,更多信息请参考该文,win用户请参考该文
大功告成
$ ssh -T -v git@github.com即可