表示鏈接管道已經斷開bash
方法一:客戶端配置
在客戶端的 ~/.ssh/ config文件(如不存在請自行建立)中添加下面內容:
ServerAliveInterval 60服務器
方法二:服務器端配置
在服務器的 /etc/ssh/sshd_config 中添加以下的配置:
ClientAliveInterval 60app
方法三:臨時SSH命令配置
若是隻是臨時性的鏈接(即只做用於當前SSH),能夠直接使用 ssh 命令參數進行配置。
$ ssh -o ServerAliveInterval=60 user@sshserver
ssh
//ServerAliveInterval Sets a timeout interval in seconds after which if no data has been received from the server, ssh(1) will send a message through the encrypted channel to request a response from the server. The default is 0, indicating that these messages will not be sent to the server. This option applies to protocol version 2 only. //ClientAliveInterval Sets a timeout interval in seconds after which if no data has been received from the client, sshd(8) will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client. This option applies to protocol version 2 only.
這兩個命令前者應用在客戶機上,後者應用在服務器上,若是沒有管理員權限,那麼前者是很好的選擇。
這兩個的功能是相同的,都是開啓一個發送keep-alive包的功能,這樣會容許客戶端/服務器在必定時間內發送一個特定的包給對方,一旦超時,則說明斷線,就關閉連接。這樣就避免了連接長時間掛着致使報錯。並且,一旦再次報錯,稍等片刻即可以再次登陸。spa