SSH的 Write failed: Broken pipe 问题

问题现象:

  

 

 

   表示链接管道已经断开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

相关文章
相关标签/搜索