在添加完Coding.net的ssh-key以后,执行ssh -T [email protected]时,会出现如下错误:

1
2
Warning: Permanently added the RSA host key for IP address '106.75.4.187' to the list of known hosts.
[email protected]: Permission denied (publickey).

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

1
ssh-add ~/.ssh/id_rsa.coding

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

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

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

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

此时再执行ssh -T [email protected]命令就可以通过了

1
2
3
4
ssh -T [email protected]
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 服务,这是一个个人公钥