Prevent SSH Session Timeouts with Keep-Alive
SSH & Remote Administration
Prevent SSH Session Timeouts with Keep-Alive
🧩 The Challenge
You often lose your SSH connection during brief periods of inactivity or when traveling through unstable networks.
💡 The Fix
Configure the SSH client to automatically send periodic null packets to the server to maintain an active socket connection.
echo "ServerAliveInterval 60" >> ~/.ssh/config
⚙️ Why It Works
This setting instructs your local SSH client to send a signal to the remote server every 60 seconds, preventing firewalls or NAT gateways from closing idle connections.
🚀 Pro-Tip: Use ServerAliveCountMax to specify how many failed signals occur before the client forcibly closes the unresponsive connection.
Linux Tips & Tricks | © ngelinux.com | 7/8/2026
