项目场景:
Git项目突然不能正常使用,自己的账号下的项目。提示
Permission denied (publickey).
问题描述:
附上具体配置描述如下
.ssh文件目录:
config配置文件:
# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee_id_rsa
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_id_rsa
# codeup.aliyun
Host codeup.aliyun.com
HostName codeup.aliyun.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/git_code_id_rsa
# coding.net
Host e.coding.net
HostName e.coding.net
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
测试命令:
$ ssh -T [email protected]
Hi **! You ve successfully authenticated, but GITEE.COM does not provide shell access.
$ ssh -T [email protected]
Hi **! You ve successfully authenticated, but GitHub does not provide shell access.
$ ssh -T [email protected]
Welcome to Codeup, **!
$ ssh -T [email protected]
[email protected]: Permission denied (publickey).
原因分析:
相同配置3个成功,1个失败,不应该是git软件问题,应该是配置问题,在mac上进行相同配置一气呵成一切都是那么完美。
~ ssh -T [email protected]
CODING 提示: Hello **, You've connected to coding.net via SSH. This is a Personal Key.
**,你好,你已经通过 SSH 协议认证 coding.net 服务,这是一个个人公钥.
公钥指纹:94:db:5f:c3:87:fb:f7:e5:da:9b:4f:0c:8e:35:ef:2b
那为什么这台机器不能用呢,到底是哪里出了问题?好奇心驱动,继续寻找。经过百度发现GitHub SSH故障排除方法。
图片链接地址
检查使用的密钥:发现找到私钥文件
debug1: Offering public key: /c/Users/hoomi/.ssh/id_rsa RSA
错误信息为签名错误
no mutual signature algorithm
,原因是OpenSSH从8.8版本由于安全原因开始弃用了rsa加密的密钥
$ ssh -Tv [email protected]
OpenSSH_8.9p1, OpenSSL 1.1.1n 15 Mar 2022
debug1: Reading configuration data /c/Users/hoomi/.ssh/config
debug1: /c/Users/hoomi/.ssh/config line 17: Applying options for e.coding.net
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to e.coding.net [81.69.155.167] port 22.
debug1: Connection established.
debug1: identity file /c/Users/hoomi/.ssh/id_rsa type0
debug1: identity file /c/Users/hoomi/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.9
debug1: Remote protocol version 2.0, remote software version Go-CodingGit
debug1: compat_banner: no match: Go-CodingGit
debug1: Authenticating to e.coding.net:22 as 'git'
debug1: load_hostkeys: fopen /c/Users/hoomi/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: [email protected]
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-rsa SHA256:jok3FH7q5LJ6qvE7iPNehBgXRw51ErE77S0Dn+Vg/Ik
debug1: load_hostkeys: fopen /c/Users/hoomi/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host 'e.coding.net' is known and matches the RSA host key.
debug1: Found key in /c/Users/hoomi/.ssh/known_hosts:9
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /c/Users/hoomi/.ssh/id_rsa RSA SHA256:/jsxB0H9in7p9/U81BTwArpeQiX4OAKGxlHqL8qnzMI explicit
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /c/Users/hoomi/.ssh/id_rsa RSA SHA256:/jsxB0H9in7p9/U81BTwArpeQiX4OAKGxlHqL8qnzMI explicit
debug1: send_pubkey_test: no mutual signature algorithm
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).
图片链接地址
解决方案:
config配置文件添加
PubkeyAcceptedKeyTypes +ssh-rsa
修改后配置文件如下
# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee_id_rsa
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_id_rsa
# codeup.aliyun
Host codeup.aliyun.com
HostName codeup.aliyun.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/git_code_id_rsa
# coding.net
Host e.coding.net
HostName e.coding.net
PreferredAuthentications publickey
PubkeyAcceptedKeyTypes +ssh-rsa
IdentityFile ~/.ssh/id_rsa
测试命令
$ ssh -T [email protected]
CODING 提示: Hello **, You've connected to coding.net via SSH. This is a Personal Key.
**,你好,你已经通过 SSH 协议认证 coding.net 服务,这是一个个人公钥.
公钥指纹:94:db:5f:c3:87:fb:f7:e5:da:9b:4f:0c:8e:35:ef:2b
版权归原作者 菜鸟点滴 所有, 如有侵权,请联系我们删除。