Stop SSH from dropping your connection when you stop typing for five minutes
SSH & Remote Administration
Stop SSH from dropping your connection when you stop typing for five minutes
🧩 The Challenge
We have all been there: you are in the middle of a delicate config edit or looking at a log file, you get a ping on Slack, and when you look back at your terminal, the screen is frozen solid. It is infuriating to lose your session just because the network decided to nap for thirty seconds.
💡 The Fix
You can force the client and server to keep the conversation alive by sending empty packets in the background. It is a set-and-forget fix that stops the connection from going stale on you.
ssh -o ServerAliveInterval=60 -o ServerAliveCountMax=3 user@remote-host
⚙️ Why It Works
Setting the interval tells your client to ping the server every minute, while the count ensures it doesn’t give up immediately if a packet gets lost in a congested hop. By keeping that heartbeat constant, intermediate stateful firewalls won’t prune your connection from their tables.
🚀 Pro-Tip: Drop those settings into your ~/.ssh/config file under Host * so you never have to remember to type them again.
Linux Tips & Tricks | © ngelinux.com | 8/21/2026
