怎么设置key就不再赘述了,这里的情况是确认key已经正常设置到git服务器上了,但是clone仍然提示无权限。这时候需要进一步的提示,执行以下命令,会打印详细日志:
ssh -vv -p 29418 username@18.2.16.xx.xx
这里的ip port是我们公司内部的git服务器地址,替换对应的即可。
执行后看到一串如下日志:
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /c/Users/EDY/.ssh/id_rsa RSA SHA256:ZCFx6h7y1o0FYhS4fruJSxgZ7wyfbcL
debug1: send_pubkey_test: no mutual signature algorithm
debug1: Trying private key: /c/Users/EDY/.ssh/id_ecdsa
debug1: Trying private key: /c/Users/EDY/.ssh/id_ecdsa_sk
debug1: Trying private key: /c/Users/EDY/.ssh/id_ed25519
debug1: Trying private key: /c/Users/EDY/.ssh/id_ed25519_sk
debug1: Trying private key: /c/Users/EDY/.ssh/id_xmss
debug1: Trying private key: /c/Users/EDY/.ssh/id_dsa
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
username@182.16.xx.xx: Permission denied (publickey).
可以看到trying的时候在.ssh目录下尝试了多种key,唯独没有我生成的rsa的key。可见应该还是兼容性问题,服务端只支持rsa的方式,客户端的版本比较高,可能默认不再兼容rsa的加密。一通查询后,果然是如此,只要在config文件加上rsa的支持即可。
解决方式:
在.ssh/config文件中增加rsa支持
PubkeyAcceptedKeyTypes +ssh-rsa