问题描述
在Windows中的虚拟机中安装Ubuntu后,通过SSH在Windows连接Ubuntu报错。
问题分析
ssh升级后,为了安全起见,默认不再采用原来的一些加密算法,需要手动添加进去。
解决方式
修改Ubuntu中的配置文件
在Ubuntu的终端中输入命令:sudo vi /etc/ssh/sshd_config
在配置文件sshd_config的末尾添加以下内容:
Ciphers 3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com
MACs hmac-sha1,hmac-sha1-96,hmac-sha2-256,hmac-sha2-512,hmac-md5,hmac-md5-96,umac-64@openssh.com,umac-128@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-md5-etm@openssh.com,hmac-md5-96-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com
KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,curve25519-sha256@libssh.org
重启sshd服务
在Ubuntu的终端中输入命令:sudo /etc/init.d/ssh restart
重启sshd服务失败
如果重启sshd服务失败,且终端提示如下:
Job for ssh.service failed because the control process exited with error code. See “systemctl status ssh.service” and “journalctl -xe” for details.
查找失败原因
在Ubuntu的终端中输入命令:sshd -T
-
如果此时Ubuntu提示的是Bad SSH2 mac spec,则在终端输入命令:ssh -Q mac,然后把终端返回的信息复制替换掉上文MACs后的内容
-
-
如果此时Ubuntu提示的是Bad SSH2 cipher spec,则在终端输入命令:ssh -Q mac,然后把终端返回的信息复制替换掉上文Ciphers后的内容