![](https://www.scmgalaxy.com/tutorials/wp-content/uploads/2024/07/image-1.png)
When using a 5G internet connection, SSH sessions can sometimes get disconnected due to inactivity. To prevent this, you can adjust the settings on both the client and server sides to keep the connection alive. Here are the steps to configure these settings:
On the SSH Client Side
- Modify SSH Config File:
- Edit the SSH client configuration file, typically located at
~/.ssh/config
. If the file does not exist, you can create it. - Add the following lines to the configuration file to enable keep-alive packets:
- Edit the SSH client configuration file, typically located at
Host *
ServerAliveInterval 60
ServerAliveCountMax 5
- ServerAliveInterval: This setting specifies the interval (in seconds) between keep-alive messages sent to the server. Setting it to 60 seconds means the client will send a keep-alive message every 60 seconds.
- ServerAliveCountMax: This setting specifies the number of keep-alive messages that can be sent without receiving a response from the server before the client disconnects. Setting it to 5 means the client will wait for 5 intervals (5 minutes in this case) before disconnecting.
- Using Command Line Options:
- You can also set these options directly when initiating an SSH session:
ssh -o ServerAliveInterval=60 -o ServerAliveCountMax=5 user@hostname
Latest posts by rajeshkumar (see all)