Site icon New Generation Enterprise Linux

Stop the hang when your ssh session loses its mind

SSH & Remote Administration

Stop the hang when your ssh session loses its mind

🧩 The Challenge

You know that feeling when your network glitches for a second and your terminal just freezes, leaving you unable to even type a kill signal? I’ve spent way too much time staring at a dead cursor waiting for a timeout that never happens.

💡 The Fix

Tell your ssh client to send a keepalive packet every few seconds. It makes your connection way more resilient to transient network drops and prevents those infuriating permanent hangs.

echo "ServerAliveInterval 15" >> ~/.ssh/config

⚙️ Why It Works

Setting this value forces the client to ping the server if no data has been received for that many seconds, which lets the local process realize the socket is dead rather than waiting forever. It effectively turns a hung session into a clean exit.

🚀 Pro-Tip: Set ServerAliveCountMax to 3 if you want to be extra aggressive about nuking zombie connections.

Linux Tips & Tricks | © ngelinux.com | 11/30/2026

0 0 votes
Article Rating
Exit mobile version