念念不忘
必会回响

Permission denied (publickey)的解决办法

在添加完Coding.net的ssh-key以后,执行ssh -T git@git.coding.net时,会出现如下错误:

Warning: Permanently added the RSA host key for IP address '106.75.4.187' to the list of known hosts.
git@git.coding.net: Permission denied (publickey).

这个错误在之前添加gitee时也遇到过,当时忘记怎么处理了,翻了下history,发现执行如下命令即可解决:

ssh-add ~/.ssh/id_rsa.coding

id_rsa.coding是你生成ssh-key时指定的名称,例如本文生成ssh-key的命令为:

ssh-keygen -t rsa -f ~/.ssh/id_rsa.coding -C "Coding"

接着在~/.ssh/config中加入如下配置:

Host coding.net
    IdentityFile ~/.ssh/id_rsa.coding
    User xxx (此处填写coding的用户名)

此时再执行ssh -T git@git.coding.net命令就可以通过了

ssh -T git@git.coding.net
Warning: Permanently added the RSA host key for IP address '123.59.85.99' to the list of known hosts.
Coding 提示: Hello oka, You've connected to Coding.net via SSH. This is a personal key.
xxx,你好,你已经通过 SSH 协议认证 Coding.net 服务,这是一个个人公钥

 

赞(0) 打赏
未经允许不得转载:堆上小栈 » Permission denied (publickey)的解决办法

评论 抢沙发

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

登录

找回密码

注册