In most cases, the client configuration needs to be set to a lower value than the default timeout of the server. This is usually due to a network disconnect between the client and the server. If it goes through the ClientAliveInterval twice without getting a signal back from the client, the server will close the SSH session. This will send a signal from the server to the client every 60 seconds. Likewise, we can set a similar configuration on the Server: ClientAliveInterval 60 If it goes through the ServerAliveInterval twice without getting a signal back, it will close the SSH session. Instead of having the client continue to send signals every 240 seconds, the client will now also listen for a signal back from the server. To configure a timeout on the client, we can use the ServerAliveCountMax keyword in the same config file as above: Host * Many of these cloud hosting platforms charge per minute that a server is used, and keeping the SSH session alive constantly could run up the costs even if we’re not actively using it. However, if we are hosting our server on a platform such as AWS E3, it could get costly if we don’t set a timeout. If the server we connect to is one that we maintain ourselves, then there may not be a strong reason to set a timeout.
By running nano $HOME/.ssh/config we open the config file in a basic text editor inside the terminal/bash window. We can now add our rules to the configuration file by using any text editor, such as nano or vim. Once we create the config file, we must also run the chmod command to make sure the file is not world-readable: $ chmod 600 $HOME/.ssh/config We can do so by using the touch command: $ touch $HOME/.ssh/config Either way, we are now ready to create the config file. If this folder already exists, we’ll see a message that says “File exists.” If the folder did not exist, we won’t see any output. ssh folder if it’s not already there: $ mkdir $HOME/.ssh If we see the above message, then we must create the config file manually. We may get a message saying, “no file found” if we open up a terminal and type in cat $HOME/.ssh/config: $ cat $HOME/.ssh/configĬat: /.ssh/config: No such file or directory The location of the client-side config file is $HOME/.ssh/config.