no matching host key type found. Their offer: ssh-rsa 问题解决

在升级到MacOSVentura13.0.1后,用户遇到ssh使用指定密钥登录服务器失败的问题,由于OpenSSH的更新,默认禁用了ssh-rsa算法。解决方法包括在ssh命令中临时指定算法或永久修改~/.ssh/config文件添加配置项。这是由于SHA-1算法的安全性降低,未来将被弃用。对于仍使用ssh-rsa的旧服务器,本地启用该算法是临时对策。
摘要由CSDN通过智能技术生成

最近升级了Mac OS Ventura 13.0.1后发现ssh指定密钥登录服务器失败。

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

进入当前用户的.ssh目录发现比之前系统多了一个config文件

查看sshd版本,发现升级了,需要指定算法参数

解决办法:

方法1. ssh命令指定算法,每次指定比较麻烦

ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa  user@host -p 2222
方法2. 修改ssh配置文件 ~/.ssh/config, 增加配置项,一劳永逸

HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa

上面配置默认对所有连接的服务器生效,也可以通过制定服务器使部分服务器生效

Host 172.16.x.x
HostName k8s-node001
User root
Port 22
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa
为什么会有这个错误
Future deprecation notice It is now possible[1] to perform chosen-prefix attacks against the SHA-1 algorithm for less than USD$50K.

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.

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 也是一种权宜之法.

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值