Disable SSH Timeout on EC2
The automatic logout on EC2 running Debian 12 is typically due to the SSH session timing out or a terminal session timeout. You can disable these timeouts by adjusting the SSH and shell settings. Here are the steps you can follow:
1. Disable SSH Timeout
To prevent SSH from timing out, you can modify the SSH server configuration:
Open the SSH server configuration file:
Find and set the following parameters (if they are not present, add them):
ClientAliveInterval 120
sets the interval (in seconds) after which the server will send a message to the client requesting a response to keep the connection alive. In this case, it is set to 120 seconds.
ClientAliveCountMax 720
sets the number of client alive messages that can be sent without receiving any messages back from the client. In this case, it is set to 720. Combined with the ClientAliveInterval
, this allows for a 24-hour (120 seconds * 720) timeout.
Save the file and exit the editor (Ctrl+O, Enter to save, Ctrl+X to exit).
Restart the SSH service to apply the changes:
Last updated
Was this helpful?