SSH & Remote Administration
Stop your SSH session from hanging when your local network flaps
đź§© The Challenge
You’re deep into a configuration file, the office Wi-Fi blips for a second, and your terminal goes completely unresponsive. You end up sitting there staring at a blinking cursor for ten minutes because SSH is still trying to talk to a ghost connection.
đź’ˇ The Fix
Tweak your SSH client settings to send regular heartbeats and automatically drop the connection if the server doesn’t respond. It saves you from having to kill your shell process every single time your laptop loses signal.
echo "ServerAliveInterval 15" >> ~/.ssh/config && echo "ServerAliveCountMax 3" >> ~/.ssh/config
⚙️ Why It Works
Setting the interval forces the client to send a null packet every 15 seconds to check the connection, and the count determines how many times it can miss a response before giving up. It keeps your sessions snappy and kills the dead ones before they start cluttering your process list.
🚀 Pro-Tip: Add these to your global ~/.ssh/config so you don’t have to remember them for every new project host you manage.
Linux Tips & Tricks | © ngelinux.com | 12/5/2026
