How do I define an inactivity timeout for PSMP SSH Connections?
Question
Environment
v7.2;v7.5;v7.6;v8.0;v8.0 Beta;8.1;v8.2;v8.5;v8.6;v9.0;v9.1;v9.2;9.3;9.5;9.6;9.7;9.8;9.9;11.1;11.2;11.3;11.4;11.5;11.6;11.7;12.0;12.1;12.2;11.9;11.8;12.4;12.3;12.5;14.0;14.2 Privileged Access Manager (PAM, self-hosted) PSMP
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
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:
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.
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.
Host *:
-
This line specifies that the following settings apply to all SSH hosts. The asterisk (
*) is a wildcard that matches any host.
ServerAliveInterval 10:
-
This setting instructs the SSH client to send a "keep-alive" message to the server every 10 seconds. This helps ensure that the connection remains active, even if there is no data being transmitted.
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.
Additional Information
Details
How do I define an inactivity timeout for PSMP SSH Connections?
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.