1. 程式人生 > >systemctl status ssh.service 服務重啟出現報錯

systemctl status ssh.service 服務重啟出現報錯

Case:

ubuntu在從Ubuntu 16.04 LTS 升級到18.04 的時候,執行 do-release-upgrade -d 後,發現ssh無法登陸伺服器,

Solution:

1、通過ssh -v [email protected],發現如下報錯:

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登陸問題解決!