DeveloperBreeze

How to Stop SSH From Timing Out

If your SSH session closes after a minute of inactivity, it’s usually caused by idle timeouts. You can fix this with keep-alive settings on both the server and client.

1. Server-Side Fix

Edit the SSH daemon config:

sudo nano /etc/ssh/sshd_config

Add these lines:

ClientAliveInterval 60
ClientAliveCountMax 3

This makes the server send a keep-alive packet every 60 seconds, allowing up to 3 missed replies before disconnecting.

Restart SSH:

sudo systemctl restart sshd

2. Client-Side Fix

On your local machine, edit or create:

nano ~/.ssh/config

Add:

Host *
    ServerAliveInterval 60
    ServerAliveCountMax 3

This ensures your SSH client pings the server regularly.


That’s it. With these changes, your SSH session will stay alive and won’t drop after just a minute.

Related Posts

More content you might like

Tutorial
bash

How to Check and Configure SSH Timeout Settings on Your Server

Configuring SSH timeout settings is a simple but effective way to enhance the security and efficiency of your server. By setting appropriate timeouts, you can automatically close inactive sessions, reducing the risk of unauthorized access and conserving server resources. Regularly review and adjust these settings based on your server’s usage patterns to maintain optimal performance and security.

Now that you know how to check and configure SSH timeout settings, you can keep your server secure and running efficiently. Remember to always test your changes in a controlled environment before applying them to a production server.

Aug 19, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Be the first to share your thoughts!