Stop the constant SSH connection drops when your laptop sleeps
SSH & Remote Administration
Stop the constant SSH connection drops when your laptop sleeps
🧩 The Challenge
Nothing ruins a workflow faster than coming back from lunch only to find your terminal hung on a dead TCP session. You try to hit enter, but it just sits there staring at you like a ghost.
💡 The Fix
Just tell your SSH client to send a heartbeat packet every few seconds so the connection stays alive even if the network goes quiet. It’s a simple config change that turns a flaky connection into a rock-solid one.
echo "ServerAliveInterval 60" >> ~/.ssh/config
⚙️ Why It Works
Setting this value forces your client to send a null packet to the server if nothing has been sent for sixty seconds, which prevents NAT gateways or firewalls from dropping the idle connection. It keeps the pipe open without you having to touch a thing.
🚀 Pro-Tip: Add ServerAliveCountMax 3 if you want the client to finally give up after three failed heartbeats instead of waiting forever.
Linux Tips & Tricks | © ngelinux.com | 11/19/2026
