问题描述
之前在Ubuntu18.04上按照博客文章《 ubuntu18.04系统搭建以及配置 》配置ssh 登录是没有问题的,但最新新的项目需要安装Ubuntu20.04,在安装了ubuntu20.04后,以前老版本的secureCRT通过ssh连接后报错
Key exchange failed.
No compatible key exchange method. The server supports these methods: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256
解决方法
1.修改ssh_config
sudo vi /etc/ssh/ssh_config
打开下面这两行的注释
2.修改sshd_config
sudo vi /etc/ssh/sshd_config
再加入下面的代码
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
重启sshd服务
sudo service sshd restart
重新通过secureCRT连接Ubuntu20.04,发现可以了。