用 Xshell 連接服務器總是報錯 :
Connection closed by foreign host.
Disconnected from remote host...
1
2
原因可能是 SSH 服務器沒設置保活時間間隔 , 具體設置如下 :
# vim /etc/ssh/sshd_config
1
添加兩行 , 或去掉注釋 :
ClientAliveInterval 60
ClientAliveCountMax 3
1
2
重啟 SSH 服務 :
# /etc/init.d/ssh restart
# systemctl restart sshd
1
2
ClientAliveInterval 參數數值是秒 , 是指超時時間 , 上面設置的是一分鍾 ;
ClientAliveCountMax 設置允許超時的次數 , 上面設置的是允許三次 , 之后就關閉連接 ;