ssh no matching key exchange method found错误

我在使用ubuntu2021 ssh 登录另一个系统时出现如下报错:

Unable to negotiate with 192.168.2.1 port 22: no matching key exchange method found. Their offer: diffie-hellman-group1                        4-sha1,diffie-hellman-group1-sha1,kexguess2@matt.ucc.asn.au

我的ubunt版本

#42~20.04.1-Ubuntu SMP Tue Sep 28 20:41:07 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

从网上找了许多方法,最后解决了。

方法一:

ssh -o KexAlgorithms=+diffie-hellman-group1-sha1 root@192.168.2.1

方法二:

修改~/.ssh/config文件加入以下代码,注意是~/.ssh/config,网上有人说修改/etc/ssh/sshd_config,我修改sshd_config文件后并不起作用。

Host *
     KexAlgorithms +diffie-hellman-group1-sha1

重启ssh

service ssh restart

推荐使用第二种方法,因为第二种方法是一劳永逸的。


版权声明:本文为alfiy原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。