Question
How do I configure an idle session to stay alive for PSMP SSH Connections?
Answer
Some admins want to define the SSH session to stay active when no traffic is being sent. The PSMP will honor the target server configuration for these settings; The typical default is set to keep the ssh connection alive forever.
In OpenSSH, this can be achieved by combining ClientAliveCountMax and ClientAliveInterval options in sshd_config file
- ClientAliveCountMax:
This indicates the total number of checkalive message sent by the ssh server without getting any response from the ssh client, before termination of the session. The default is 0; meaning the server will not terminate the session on no response.
- ClientAliveInterval:
Sets a timeout interval in seconds after which, if no data has
been received from the client, sshd will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client.
For example, to send a checkalive packet after 1 hour of inactivity, the configuration would be the following:
1. Edit the sshd_config file located in /etc/ssh/
2. Register the parameters mentioned above as below:
ClientAliveInterval 3600
ClientAliveCountMax 0
3. Restart the service
Alternative Option:
Open the PuTTY application, and go to the Options panel (labeled "Category") on the left of the window.
->Select (click) the "Connection" item.
->In the "Sending of null packets to keep the session active" area on the right, change the default value of "Seconds between keepalives" from 0 (turn off) to 1800 (30 minutes).
->Select the "Enable TCP keepalives (SO_KEEPALIVE option)" check box. Note: This option may not be available in older versions of the PuTTY client.
In addition to the Enable TCP keepalives in PuTTY you will need to add ServerAliveInterval and ServerAliveCountMax to the PSMP ssh_config file as follow:
host *
ServerAliveInterval 10
ServerAliveCountMax 1
ServerAliveCountMax 1:
-
This setting specifies the maximum number of "keep-alive" messages that can be sent without receiving a response from the server before the client terminates the connection. In this case, if the client sends one "keep-alive" message and does not receive a response, it will disconnect.
Note:
- You may need to adjust these settings to meet any idle (network) session timeouts within the environment.
- Some environments/networks will not forward the 'clientalive' packet. (In which case you would need to change the network configuration)
- It is also possible to cause inactive sessions to timeout using the TMOUT environment variable in the shell on the target server. This environment variable is in seconds and will cause the shell to exit if there is no activity for $TMOUT seconds. This causes the PSM for SSH connection to close. To check if this is set, simply enter the env command in a shell and see if there is a value for TMOUT.
Q:
How do I define an inactivity timeout for PSMP SSH Connections?
A:
Some admins want to define a timeout for inactivity session through PSMP
On most of Linux releases, the default is set to keep ssh connection alive forever
In OpenSSH, this can be achieved by combining ClientAliveCountMax and ClientAliveInterval options in sshd_config file
- ClientAliveCountMax: This indicates the total number of checkalive message sent by the ssh server without getting any response from the ssh client
- ClientAliveInterval: This indicates the timeout in seconds. After x number of seconds, ssh server will send a message to the client asking for response
For example to leave the session open for maximum 8 hours of inactivity, the configuration would be the following:
1 - Edit the sshd_config file located in /etc/ssh/
2 - Register the parameters mentioned above as below:
ClientAliveInterval 28800
ClientAliveCountMax 0
3 - Restart the service
Note:
It is also possible to cause inactive sessions to timeout using the TMOUT environment variable in the shell on the target server. This environment variable is in seconds and will cause the shell to exit if there is no activity for $TMOUT seconds. This causes the PSM for SSH connection to close.
To check if this is set, simply enter the env command in a shell and see if there is a value for TMOUT.