6

2021-47: SSH 弃用 SHA-1 哈希算法

 3 years ago
source link: https://xuanwo.io/reports/2021-47/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

2021-47: SSH 弃用 SHA-1 哈希算法

今天 SSH 一个服务器的时候突然报错:

[email protected]: Permission denied (publickey).

加上 -v 看一下具体的报错内容:

debug1: Offering public key: /home/xuanwo/.ssh/example RSA SHA256:xxxxx explicit agent
debug1: send_pubkey_test: no mutual signature algorithm

跳过前面无关的信息,发现 ssh 在提供了我预期的 public key 之后立马返回了 no mutual signature algorithm 错误。这时候才想起很久以前群友似乎讨论过 OpenSSH 弃用 SSH-RSA 的事情,看来终于是被我撞上了。如参考资料中的 OpenSSH 8.8 Release 所说,SHA-1 哈希算法在密码学上已经不再安全,这个版本默认禁用了使用 SHA-1 哈希算法的 RSA 签名。

首先是寻找一个 Workaround,先把工作搞定。我们可以为这个 Host 单独启用这个算法的支持,在 ~/.ssh/config 中增加如下配置:

Host old-host
    PubkeyAcceptedAlgorithms +ssh-rsa

或者在命令中通过 -o 来添加这个参数:

ssh [email protected] -o PubkeyAcceptedAlgorithms=+ssh-rsa

然后我们需要使用一个彻底的解决方案:更换 SSH Key。我这里选择使用 ed25519 椭圆曲线算法,注意这个算法还没有被广泛支持,需要访问老版本 OpenSSH 的话,可以选择 ECDSA 算法。

ssh-keygen -t ed25519 -C <hostname/email>

接下来只需要更新各个服务器上的公钥即可~



About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK