在添加完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 服务,这是一个个人公钥