背景
- 使用xshell链接远程服务器时报错,提示xshell找不到匹配的key exchange算法
- 笔者使用xshell4,远程服务器是ubuntu20.04
原因分析
和ubuntu18.04相比,ubuntu20.04的key exchange算法进行了升级(从diffie-hellman-group14-sha1升级到了diffie-hellman-group14-sha256),而xshell4版本还不支持diffie-hellman-group14-sha256算法,从而导致该错误
解决方法
方法一
- 升级xshell
方法二
设置兼容性,在Ubuntu20.04中增加key exchange算法diffie-hellman-group14-sha1,从而兼容xshell4。
具体做法是,在服务器端执行以下命令:
# 添加diffie-hellman-group14-sha1算法
echo "KexAlgorithms +diffie-hellman-group14-sha1" >>/etc/ssh/sshd_config
# 重启ssh服务
systemctl restart sshd(或者service ssh restart)