## 解决 ssh 找不到对应主机密钥类型 > 解决更新到openssh8.8P1及以上版本之后提示所选用户密钥未在远程主机上注册的问题 解决办法 ---- 如果最近升级到了 openssh 8.8 版,你会发现连接某些之前连接得好好的服务器突然无法连接: ```bash Unable to negotiate with x.x.x.x port 2222: no matching host key type found. Their offer: ssh-rsa ``` 解决办法是 ssh 命令指定算法: ```bash ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa user@host -p 2222 ``` 上面比较麻烦,可以修改 ssh 配置文件 `~/.ssh/config`,对于无法成功连接的 host,增加以下配置项: ```bash HostKeyAlgorithms +ssh-rsa PubkeyAcceptedKeyTypes +ssh-rsa ``` 完整的配置如下: ```bash Host jump Port 2222 HostName x.x.x.x User *** IdentityFile ~/.ssh/id_rsa UseKeychain yes AddKeysToAgent yes PreferredAuthentications publickey HostKeyAlgorithms +ssh-rsa PubkeyAcceptedKeyTypes +ssh-rsa ``` 脚本命令 ```bash echo "HostKeyAlgorithms +ssh-rsa PubkeyAcceptedKeyTypes +ssh-rsa" >> /etc/ssh/sshd_config systemctl restart sshd ssh -V ``` 问题原因 ---- 根据 [OpenSSH 8.8 Release Notes](https://www.openssh.com/txt/release-8.8) 信息: ```bash This release disables RSA signatures using the SHA-1 hash algorithm by default. This change has been made as the SHA-1 hash algorithm is cryptographically broken, and it is possible to create chosen-prefix hash collisions for