Stop your SSH session from freezing when your laptop goes to sleep
SSH & Remote Administration
Stop your SSH session from freezing when your laptop goes to sleep
🧩 The Challenge
You know that feeling when you close your laptop lid on the train, pop it open an hour later, and your terminal is just hanging there like a ghost? It drives me nuts waiting for the TCP timeout to realize the connection is dead so I can finally start typing again.
💡 The Fix
You can tell your local SSH config to send a tiny heartbeat packet every so often, which keeps the connection alive and lets your client notice if the server actually dropped off the map.
Host *
ServerAliveInterval 60
ServerAliveCountMax 3
⚙️ Why It Works
Setting these parameters forces the client to send a null packet through the encrypted tunnel, preventing middlebox routers from killing the session during idle periods.
🚀 Pro-Tip: Add this to ~/.ssh/config on your local machine and you’ll never have to kill a frozen shell again.
Linux Tips & Tricks | © ngelinux.com | 8/10/2026
