Steps to Set SSH Timeout on Your Server
-
Connect to the Server via SSH
Run the following command to log in to your server:ssh <username>@<ip_address> -p <port>
-
Edit the SSH Configuration File
Open the SSH configuration file using the nano editor:sudo nano /etc/ssh/sshd_configNote: You can use
vimor any other text editor if preferred.
-
Locate the ClientAliveInterval Setting
In the opened file, find the line containingClientAliveInterval. If it is commented out, remove the#at the beginning.
-
Set the Desired Timeout
Modify or add the following line with your preferred timeout value in seconds:ClientAliveInterval 300
-
Save and Apply Changes
- Save the file (
CTRL + X, thenY, and pressEnter). - Restart the SSH service to apply the changes:
sudo systemctl restart sshd
- Save the file (