Site icon New Generation Enterprise Linux

Stop letting your SSH sessions hang forever when the network drops

SSH & Remote Administration

Stop letting your SSH sessions hang forever when the network drops

đź§© The Challenge

You know that soul-crushing feeling when you’re mid-command and your coffee-shop Wi-Fi blinks, leaving your terminal frozen while you hammer Ctrl+C for an eternity? It’s enough to make you want to throw the laptop out the window.

đź’ˇ The Fix

Tell your local SSH client to proactively send keep-alive packets so it realizes the connection is toast before you notice the lag. It makes your remote sessions feel rock-solid even on flaky internet.

echo "ServerAliveInterval 15" >> ~/.ssh/config && echo "ServerAliveCountMax 3" >> ~/.ssh/config

⚙️ Why It Works

By forcing the client to ping the server every 15 seconds, you force the TCP stack to realize the connection died rather than waiting for the kernel’s default timeout, which takes forever.

🚀 Pro-Tip: Use the -o flag if you just want to test it once without touching your config.

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

0 0 votes
Article Rating
Exit mobile version