SSH的 Write failed: Broken pipe 問題


問題現象:

  

 

 

   表示連接管道已經斷開

 

解決方法:  

  方法一:客戶端配置
  在客戶端的 ~/.ssh/ config文件(如不存在請自行創建)中添加下面內容:
  ServerAliveInterval 60

  方法二:服務器端配置
  在服務器的 /etc/ssh/sshd_config 中添加如下的配置:
  ClientAliveInterval 60

  方法三:臨時SSH命令配置
  如果只是臨時性的連接(即只作用於當前SSH),可以直接使用 ssh 命令參數進行配置。
  $ ssh -o ServerAliveInterval=60 user@sshserver

//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包的功能,這樣會允許客戶端/服務器在一定時間內發送一個特定的包給對方,一旦超時,則說明斷線,就關閉鏈接。這樣就避免了鏈接長時間掛着導致報錯。而且,一旦再次報錯,稍等片刻便可以再次登錄。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM