当前位置:   article > 正文

no matching host key type found. Their offer: ssh-rsa_no matching host key found

no matching host key found

mac升级系统后ssh连接远程报如下错误:

Unable to negotiate with x.x.x.x port 2222: no matching host key type found. Their offer: ssh-rsa

查看自己的ssh版本:

OpenSSH_9.4p1, LibreSSL 3.3.6

经过查看资料 发现openssh 8.8-p1版本以上就会出现如上问题,或者仓库无法clone

解决办法一:ssh命令指定算法

ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa  user@host -p 2222

上面比较麻烦, 可以修改ssh配置文件 ~/.ssh/config, 对于无法成功连接的host, 增加配置项:

  1. HostKeyAlgorithms +ssh-rsa
  2. PubkeyAcceptedKeyTypes +ssh-rsa

至此问题得以解决。

原因分析:

根据 OpenSSH Release Notes:

  1. Future deprecation notice It is now possible[1] to perform chosen-prefix attacks against the SHA-1 algorithm for less than USD$50K.
  2. In the SSH protocol, the “ssh-rsa” signature scheme uses the SHA-1 hash algorithm in conjunction with the RSA public key algorithm. OpenSSH will disable this signature scheme by default in the near future.
  3. Note that the deactivation of “ssh-rsa” signatures does not necessarily require cessation of use for RSA keys. In the SSH protocol, keys may be capable of signing using multiple algorithms. In particular, “ssh-rsa” keys are capable of signing using “rsa-sha2-256” (RSA/SHA256), “rsa-sha2-512” (RSA/SHA512) and “ssh-rsa” (RSA/SHA1). Only the last of these is being turned off by default.

也就是说 8.8p1 版的 openssh 的 ssh 客户端默认禁用了 ssh-rsa 算法, 但是对方服务器只支持 ssh-rsa, 当你不能自己升级远程服务器的 openssh 版本或修改配置让它使用更安全的算法时, 在本地 ssh 针对这些旧的ssh server重新启用 ssh-rsa 也是一种权宜之法

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/789871
推荐阅读
相关标签
  

闽ICP备14008679号