+2 votes
in Operating Systems by (14.4k points)
After connecting to a server from my laptop, if I do not press any key for some time, the connection is lost. I need to re-login to the server, which is frustrating.

How can I increase the SSH connection timeout so that even if I do not press any key, I do not lose the connection?

1 Answer

0 votes
by (22.9k points)

On your laptop, edit the ssh_config file to send null packets to the server at some interval. This way, you will not lose the connection.

1. Open the ssh_config file in an editor.

vi /etc/ssh/ssh_config

2. Add the following line at the end of the file. This change will send null packets to the server every 60 seconds.

ServerAliveInterval 60

If you have "root" privileges on the server machine, make similar changes in the ssh_config file on the server. Thus, if you are not connecting from your laptop, you will not have to worry about timeout.

...