$ ssh -T -v [email protected]_在本地用ssh连接github出错[email protected]: Permission denied (publickey).

$ ssh -T -v [email protected]报错:

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.
[email protected]: 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文件,添加我生成的private key文件到该文件夹下,然后执行下面命令:

$ ssh-add ~/.ssh/Jack_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)

如此,则配置成功!

大功告成

$ ssh -T -v [email protected]即可

原文地址:https://www.cnblogs.com/lyzz1314/p/12350098.html

时间: 2024-10-07 10:56:45