在新电脑上安装了git(2.34.1),使用git bash进行测试时提示Permission denied (publickey)

但奇怪的是,使用自带cmd测试,却能够正常连接

测试命令:ssh -T -v git@e.coding.net

使用git bash测试认证被拒绝:

debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key:  C:\\Users\\xxxxxx\\.ssh\\workPC RSA ... agent
debug1: send_pubkey_test: no mutual signature algorithm <-- ssh-rsa is not enabled 
debug1: No more authentication methods to try.
xxx@e.coding.net: Permission denied (publickey).

使用cmd测试能够通过认证:

Authenticated to e.coding.net ([81.69.155.167]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
CODING 提示: Hello xxxxx, You've connected to coding.net via SSH. This is a Personal Key.
xxxxx,你好,你已经通过 SSH 协议认证 coding.net 服务,这是一个个人公钥.
公钥指纹:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 1992, received 1700 bytes, in 0.0 seconds

检查了.ssh/config,know_hosts密钥,都正常。开始百思不得姐。

遂搜索,得知:高版本OpenSSH没有启用ssh-rsa

猜测是Windows10本身的OpenSSL版本低,支持ssh-rsa;而Git Bash的OpenSSL版本较高,不支持ssh-rsa

解决方法有两种:

  1. 添加 PubkeyAcceptedKeyTypes +ssh-rsa 配置
  2. 更换密钥生成算法,使用ed25519算法生成
    ssh-keygen -t ed25519 -C "1@1.com"

重新生成密钥并在coding配置后,问题解决~

参考:https://confluence.atlassian.com/bitbucketserverkb/ssh-rsa-key-rejected-with-message-no-mutual-signature-algorithm-1026057701.html

-EOF-

最后修改:2022 年 01 月 21 日
如果觉得我的文章对你有用,请随意赞赏