ubuntu 修改/etc/ssh/sshd_config配置文件后重启ssh服务报错的解决办法

问题描述:

  我在使用sshsecureshell登录ubuntu 20.04时出现错误server responded "algorithm negotiation failed”,然后按照百度到的教程修改了/etc/ssh/sshd_config的配置文件,在文件的最后添加了一段表示加密算法的内容,
在百度上看到的要增加的内容如下(是错的,要进行修改),我会把正确的内容放在最后

Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blowfish-cbc,cast128-cbc

MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha1-96,hmac-md5-96

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

之后重启ssh服务时出现错误,提示
Job for ssh.service failed because the control process exited with error code. See “systemctl status ssh.service” and “journalctl -xe” for details.

Job for ssh.service failed because the control process exited with error code.
See "systemctl status ssh.service" and "journalctl -xe" for details.

解决过程:

首先根据提示输入systemctl status ssh.service命令
systemctl status ssh.services
结果如下

在这里插入图片描述输入sshd -T命令查看具体错误原因

sshd -T
/etc/ssh/sshd_config line 128: Bad SSH2 mac spec 'hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha1-96,hmac-md5-96'.

这里的内容表示是最后面添加的MACs的内容有错误,可能是ssh版本不一致或者是什么导致的,我们要修改的就是这段内容
输入ssh -Q mac命令查看ssh支持的Macs有那些,把这些内容替换到最后增加的mac中即可
在这里插入图片描述修改之后再次重启ssh如果不出错误就没问题了

如果sshd -T提示的错误是 Bad SSH2 mac spec,就使用ssh -Q mac查看然后修改Macs的内容
如果错误是Bad SSH2 cipher spe,就使用ssh -Q cipher,然后修改配置文件中的cipher的内容

最后附上正确的内容

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
  • 9
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值