ssh连接服务器命令_如何查看ssh版本

(34) 2024-09-03 22:01:03

好不容易升到最新版本获取全新体验,结果泪目了~

报错原因:ssh工具版本太低,OpenSSL版本升的比较高,有些算法不支持。

解决办法:修改ssh的配置文件 /etc/ssh/sshd_config。

                   vi /etc/ssh/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,aes 256-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@opens sh.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-sha 256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,curve25519-sha256@libssh.org 

                如图:

ssh连接服务器命令_如何查看ssh版本 (https://mushiming.com/)  第1张

                   重启ssh服务:service ssh restart

                   如果没有报错,那么you are the luky one!

                  然而,可能报如下错误。一脸懵逼,这是啥玩意?

root@wja-vm:/etc/ssh# service ssh restart Job for ssh.service failed because the control process exited with error code. See "systemctl status ssh.service" and "journalctl -xe" for details. root@wja-vm:/etc/ssh# journalctl -xe -- 结果为“failed”。 3月 17 22:20:45 wja-vm systemd[1]: ssh.service: Scheduled restart job, restart counter is at 5. -- Subject: Automatic restarting of a unit has been scheduled -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- Automatic restarting of the unit ssh.service has been scheduled, as the result for -- the configured Restart= setting for the unit. 3月 17 22:20:45 wja-vm systemd[1]: Stopped OpenBSD Secure Shell server. -- Subject: ssh.service 单元已结束停止操作 -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- ssh.service 单元已结束停止操作。 3月 17 22:20:45 wja-vm systemd[1]: ssh.service: Start request repeated too quickly. 3月 17 22:20:45 wja-vm systemd[1]: ssh.service: Failed with result 'exit-code'. -- Subject: Unit failed -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- The unit ssh.service has entered the 'failed' state with result 'exit-code'. 3月 17 22:20:45 wja-vm systemd[1]: Failed to start OpenBSD Secure Shell server. -- Subject: ssh.service 单元已失败 -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- ssh.service 单元已失败。 -- -- 结果为“failed”。 

                 调用journalctl -xe命令打印日志,可以看到画圈处十分眼熟,没错这就是问题根源。 查阅(https://kingzcheung.com/archives/116.html)后发现sshd启动的时候会读取配置文件sshd_config内容,然后和一个cipher.c文件比较,如果 ciphers 的数组配置与 sshd_config 不一样的话,就会引发 Bad SSH2 cipher spec 的错误,而升级系统刚好升级了openssh,但是配置并没有改变,所以导致配置与版本不一致。

ssh连接服务器命令_如何查看ssh版本 (https://mushiming.com/)  第2张

通过使用ssh -Q cipher命令查看系统版本的ciphers数组内容,置换到前面的sshd_config文件。

oot@wja-vm:/etc/ssh# root@wja-vm:/etc/ssh# ssh -Q cipher 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 

同样,使用ssh -Q macs,ssh -Q kexalgorithms进行相关内容置换即可。

置换后保存,重启ssh,完美解决。

所查阅的相关资料链接:CSDN博主「ance779」的原创文章,原文链接:https://blog.csdn.net/ance779/article/details/

                                 博客园博主原文链接:https://www.cnblogs.com/xuanbjut/p/13379717.html

THE END

发表回复