Friday, February 23, 2007
Prevent Timeouts in SSH
Many routers timeout the connection after some period of inactivity. For users of ssh, this can a big nuisance. In presence of such routers a ssh connection with no activity (for a few minutes) will disconnect automatically. The workaround is that the server and client keep talking to each other even when the user is not typing (or viewing) anything. This can be achived using one of the two ways:
Add the following two lines to /etc/ssh/sshd_config. This will make the server poll for client every 30 seconds. If the client fails to respond for 4 times (i.e., 2 mins), the server will close the connection. Note that this applies to version 2 of OpenSSH only.
ClientAliveInterval 30 ClientAliveCountMax 4
Add the following two lines to /etc/ssh/ssh_config (or $HOME/.ssh/config if you don't have root access). his will make the client poll for server every 30 seconds. If the servers fails to respond for 4 times (i.e., 2 mins), the client will close the connection. Note that this also applies to version 2 of OpenSSH only.
ServerAliveInterval 30 ServerAliveCountMax 4