Stop SSH connections from dropping when your connection is twitchy
SSH & Remote Administration
Stop SSH connections from dropping when your connection is twitchy
🧩 The Challenge
Dealing with a flaky home Wi-Fi or a spotty mobile hotspot always feels like a personal attack when your SSH session freezes every ten minutes. You end up staring at a blinking cursor, waiting for the timeout that never comes, while your shell session sits there dead in the water.
💡 The Fix
You need to tell the SSH client and the server to keep the conversation alive by sending periodic heartbeats. It saves you from having to kill and restart your terminal window whenever the network hiccup happens.
echo "ServerAliveInterval 60" >> ~/.ssh/config && echo "ServerAliveCountMax 3" >> ~/.ssh/config
⚙️ Why It Works
By setting the interval, your client sends a null packet to the server if there’s no data being sent; if the server doesn’t respond for three consecutive times, the client realizes the connection is actually gone and kills it gracefully. It basically forces the connection to stop pretending it’s alive when it’s clearly not.
🚀 Pro-Tip: Set ServerAliveInterval to 30 if your router is particularly aggressive about dropping inactive states.
Linux Tips & Tricks | © ngelinux.com | 11/10/2026
