在使用SSH管理服务器的时候,如果你很长一段时间不登录,那么很可能等待着你的就是
“Write failed: Broken pipe”
造成这个错误的原因是SSH空闲链接时间太长导致的,所以,我们需要修改SSH默认配置来让它自动关闭链接。
在SSH的配置当中,有两个命令可以实现这个功能,它们分别是
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
//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. |
这两个命令[……]