关于ServerAliveInterval和ServerAliveCountMax选项的详细说明,可以通过man ssh_config查看,这里截取部分内容
ServerAliveCountMax is left at the default, if the server becomes unresponsive, ssh will disconnect after approximately 45 seconds. This option applies to protocol version 2 only; in protocol version 1 there is no mechanism to request a response from the server to the server alive messages, so disconnection is the responsibility of the TCP stack.
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, or 300 if the BatchMode option is set. This option applies to protocol version 2 only. ProtocolKeepAlives and SetupTimeOut are Debian-specific compatibility aliases for this option.
我的系统是15.10.2,我在日常中经常需要随时连接到我的服务器,这本来是很简单的一个问题,我在终端下直接ssh过去就OK了,但是我今天在使用时发现我直接在终端ssh root@www.xxx.com时,能连上,但是过一段时间不操作这个界面的话,就会卡死。同样的方法连接本地服务器就没有这个问题,还有的deepin终端提供的远程管理添加服务器也没有出现卡死这种状况,请问有人遇到过相同的问题吗,还请赐教。
------------------------------------------------------------------------------------------------------------------------
解决思路:既然是连接超时问题,那就从ssh的配置下手,服务器是没有问题的,问题就出在我的终端,查看终端配置cat /etc/ssh/ssh_config,发现并没有配置ssh客户端超时选项,于是手动配置,在最后添加ServerAliveInterval 30
ServerAliveCountMax 60
本地 ssh 每隔30s向 server 端 sshd 发送 keep-alive 包,如果发送 60 次,server 无回应断开连接
关于ServerAliveInterval和ServerAliveCountMax选项的详细说明,可以通过man ssh_config查看,这里截取部分内容
ServerAliveCountMax is left at the default, if the server becomes unresponsive, ssh will disconnect after approximately 45 seconds. This option applies to protocol version 2 only; in protocol version 1 there is no mechanism to request a response from the server to the server alive messages, so disconnection is the responsibility of the TCP stack.
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, or 300 if the BatchMode option is set. This option applies to protocol version 2 only. ProtocolKeepAlives and SetupTimeOut are Debian-specific compatibility aliases for this option.