拉取老版本的 Git 库报错
1.报错信息
Unable to negotiate with xx.xx.xx.xx port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss
fatal: Could not read from remote repository.
2.原因分析
这个错误发生在使用 Git 进行 SSH 连接时,因为 OpenSSH 客户端和服务器无法就安全的主机密钥算法达成一致。
服务器提供的密钥类型:ssh-rsa(弱 SHA-1 签名)和 ssh-dss(不安全的 DSA 算法)。
您的 OpenSSH 客户端(默认配置)已禁用这些不安全的算法,导致无法协商。
3.解决方法
$env:GIT_SSH_COMMAND = "ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa"
git clone git@xx.xx.xx.xx:/xx.git