Case:
ubuntu在從Ubuntu 16.04 LTS 升級到18.04 的時候,執行 do-release-upgrade -d 后,發現ssh無法登陸服務器,
Solution:
1、通過ssh -v root@77.75.154.11,發現如下報錯:
OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 77.75.154.11 [77.75.154.11] port 22.
debug1: connect to address 77.75.154.11 port 22: Connection refused
ssh: connect to host 77.75.154.11 port 22: Connection refused
2、通過登陸console 去查看ssh.service服務是否有問題。
3、查看sshd_config配置文件(/etc/ssh/sshd_config)是否配置錯誤
A: /usr/sbin/sshd -T
B: /usr/sbin/sshd -ddd
4、可以發現可能是
/etc/ssh/sshd_config 里面Ciphers配置文件有問題,故需要檢查相關的Ciphers是否支持並正確被配置。通過以下命令檢查:
使用 "sshd -t -o Ciphers=..." 命令一個個測試來找到有問題的cipher。
或者可以嘗試下面這段代碼(將您文件的84行中的所有cipher復制到echo命令中)進行批量測試:
for c in $(echo 'aes128-ctr,aes192-ctr,...' | sed -e "s/,/ /g"); sshd -t -o Ciphers=$c done
5、發現確實有不支持的Ciphers配置,把 blowfish-cbc開始的ciphers 直接都刪除,保留如下:
直接刪除,然后重啟 systemctl status ssh.service
ssh.service服務正常啟動。
至此以上ssh登陸問題解決!