gitlab ssh连接需要输密码

发布时间 2024-01-03 11:01:40作者: huim

背景:

gitlab ssh连接突然需要输密码

获取详情:

ssh连接加-v显示详情
ssh -v -T git@xx.xx.com

debug1: send_pubkey_test: no mutual signature algorithm
debug1: Offering public key: /Users/xx/.ssh/id_rsa_newigit RSA SHA256:/xxx explicit
debug1: send_pubkey_test: no mutual signature algorithm
debug1: Next authentication method: password
git@xx.xx.com's password:

原因:

以前某一天不经意把openssh给升级到9.4了。
客户端和服务器之间没有共同支持的公钥签名算法。
客户端使用的是OpenSSH_9.4,而服务器使用的是OpenSSH_6.6.1。从OpenSSH_8.8开始,ssh-rsa算法被弃用,因为它使用了不安全的SHA-1哈希函数1。
客户端和服务器都不支持更安全的rsa-sha2-256或rsa-sha2-512算法,所以公钥验证失败了,只能使用密码验证。

解决方法:

~/.ssh/config
单个HOST配置下添加

PubkeyAcceptedKeyTypes=+ssh-rsa
HostKeyAlgorithms=+ssh-rsa

ps

还是gpt好用