If no value is provided for the ServerAliveCountMax or ClientAliveCountMax, the default value of 3 will be applied to both. Connection termination is disabled by default on the server, so if don’t want to change this behavior, we don’t need to adjust the server configuration. Select that profile on the left, then select the General tab on the right. In most cases, the client configuration needs to be set to a lower value than the default timeout of the server. Open iTerm2 Go to iTerm2 > Preferences > Profiles and add a new profile (say Swift dev) using the + at the bottom left. 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. So, Ive uncommented the following and set them as follows: TCPKeepAlive Yes ClientAliveInterval 60 ClientAliveCountMax 10 From my understanding of ClientAliveInterval and ClientAliveCountMax, this should keep an SSH session alive for 10 minutes (without activity). 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 If that doesnt work then train a monkey to press enter every two minutes while. We can do so by using the touch command: $ touch $HOME/.ssh/config This is how often, in seconds, it should send a keepalive message to the server. 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.
0 Comments
Leave a Reply. |