suse ssh連線拒絕,報錯 ssh_exchange_identification: read: Connection reset by peer
操作報錯現象,ssh遠端伺服器,提示ssh_exchange_identification: read: Connection reset by peer ,但是能夠ping的通
執行ssh -v [email protected] 檢視細節詳情。(盜網上一張圖)
網上有種解決思路,說是頻繁連線遠端伺服器,導致伺服器將自己的ip加入到 /etc/hosts.deny中,可以進入伺服器的控制中心,在 vi /etc/hosts.allow
追加 sshd: ALL
再執行 service sshd restart
執行完後發現並沒有生效,那我遇到的應該不是這個問題。
再次連線遠端伺服器時,報錯connection refused,但是依舊能ping的通,懷疑ssh通道問題
去管理介面上執行 service sshd status ,發現Failed to start OpenSSH Server daemon
檢視埠22是否被佔用,lsof -i :22 發現並沒有被tcp程序繫結,
或者執行 netstat -ant|grep 22 發現並沒有被tcp 監聽
檢視程序與埠對映關係 vi /etc/services 發現 Port 22 是正確的
執行 sshd -t 看到提到了目錄 /var/lib/empty ,但是發現本地卻沒有這個目錄,跳去叢集內的其他機器發現是存在這個目錄的,而且這個目錄下為空。後續將這個目錄建立後,發現sshd服務能夠起來了。
後續在網上查詢,存在相同情況
參考 {SLES12: /var/lib/empty is missing, SSHD does not start } https://github.com/rear/rear/issues/864
同樣這個目錄的的許可權也有要求為755,當權限不對時也可能導致sshd服務起不來。