[email protected]: Permission denied (publickey)解决方案

执行ssh-add时出现Could not open a connection to your authentication agent
若执行ssh-add /path/to/xxx.pem是出现这个错误:Could not open a connection to your authentication agent,则先执行如下命令即可:

  ssh-agent bash

更多关于ssh-agent的细节,可以用 man ssh-agent 来查看

一般来说,大家在给文件起名的时候,总会起一些自己喜欢的名字,

    ssh-keygen
        生成ssh 密钥的时候,会在
    Enter file in which to save the key ("当前所在路径"): “给文件起个名字”
        这里随便起一个名字,这样问题就出来了,你起的这个名字没有和ssh内设定的名字保持一致,所以使用命令
    ssh -T git@github.com
        的时候报出Permission denied (publickey).这个错误
    当出现这个问题时,有两个比较简单的解决办法:
    1)    给文件起名字的时候使用 ‘ id_rsa ’ 这个名字
    2)    如果亲非要自己取名子,那就使用
            ssh-add ~/.ssh/你的名字
             将自己起的名字加入到ssh中

这样再使用

            ssh -T git@github.com

就会看到你想要的效果了。
注:在生成密钥的时候,请在 “ ~/.ssh/ ”目录下操作。或者生成后把文件移动到“ ~/.ssh/ ”目录下。

也可以用:

ssh-add -l 查看加入的密钥列表
ssh -v git@github.com 查看调试信息

猜你喜欢

转载自blog.csdn.net/u010859650/article/details/82348705