这个错误的原因是因为SSH协议的安全性提高了,但是客户端的OpenSSH过时了,不支持服务器发送的所有加密算法。
解决方法如下:
1.更新OpenSSH客户端
使用以下命令来更新OpenSSH客户端:
sudo apt-get update
sudo apt-get install openssh-client
2.让SSH支持旧的加密算法
在SSH配置文件中添加以下行,并保存文件:
HostKeyAlgorithms +ssh-dss
或者,修改/etc/ssh/sshd_config 文件并在其中添加以下行:
HostKeyAlgorithms +ssh-dss
KexAlgorithms +diffie-hellman-group1-sha1
3.强制使用旧的加密算法
使用以下命令来强制使用旧的加密算法:
ssh -oHostKeyAlgorithms=+ssh-dss user@hostname
或者,使用以下命令来强制使用旧的加密算法和密钥交换算法:
ssh -oHostKeyAlgorithms=+ssh-dss -oKexAlgorithms=+diffie-hellman-group1-sha1 user@hostname
如果你想保留这个设置,你需要将该命令添加到你的~/.ssh/config 文件中:
Host hostname
HostKeyAlgorithms +ssh-dss
KexAlgorithms +diffie-hellman-group1-sha1
这样就可以正常的连接到远程服务器了。