Three methods for avoiding timeouts during SSH sessions.
Use Client-side methods if you have no admin rights on the SSH servers or do not what to alter server's settings. This methods consists in instructing the client to send a keep alive every specified interval.
On Debian/Ubuntu, edit file /etc/ssh/ssh_config
and add the following line:
ServerAliveInterval 100
where 100 is the interval for sending the keep alive method in seconds. With this client-side method, the client will send a keep alive by default to every SSH server it will connect.
On every Unix system, edit file ~/.ssh/config
(create it if it does not exist yet) and add a configuration block for the specific server:
Host myserverconfig
Hostname serveraddr
User username
Port 22
Compression yes
ServerAliveInterval 100
This settings will be valid only for the current user and only for the specific server. Of course, the settings such as Hostname
, User
, etc., should be properly edited.
Use this method if you have administrative rights on the server. These settings will be valid for each user will connect to the server.
On Debian/Ubuntu, edit the file /etc/ssh/sshd_config
, changing the entries ClientAliveInterval
, TCPKeepAlive
and ClientAliveCountMax
as in the example below:
ClientAliveInterval 100
TCPKeepAlive yes
ClientAliveCountMax 99999
To apply the new settings, restart the SSH server:
sudo /etc/init.d/sshd restart