Skip to content

How to keep my SSH session alive

Neranjan Perera edited this page Oct 25, 2019 · 3 revisions

Issue:
Why do I get kicked off the cluster after only 10 minutes of being idle? How can I keep my terminal active for longer period of time?

Once you log into the cluster using a terminal your session will be active for a time period. Once you do not type anything or for been idle, the cluster will, shut you out. Then you may have to re-type your credentials again to login and have to go back to the working directory to start again.

So to avoid this you can do this:

In the server side which the ssh daemon (sshd) is running will close the connection, you the client(your computer) will become idle or does not send any information for sometime. To prevent this, and to keep the connection active, need to instruct the ssh client to send a signal to the server, once in a while.

To configure this you need to add this to your config file which can be found in $HOME/.ssh/config. If this file does not exist, you may want to create this file.

To enable sending a single to keep alive for all host, place the following content in the config file;

Host *
    ServerAliveInterval 240

This file should not be readable, so change the permissions of the file by;

chmod 600 $HOME/.ssh/config