Stop reconnecting to the same damn server every 30 seconds
SSH & Remote Administration
Stop reconnecting to the same damn server every 30 seconds
🧩 The Challenge
Ever found yourself SSHing into a host, doing a quick check, exiting, then needing to SCP a file, then SSHing back in again just moments later? That repetitive handshake and authentication dance adds up. It’s a pointless time sink when you’re just jumping in and out of the same box. Nobody tells you how much those few seconds multiply across your day.
💡 The Fix
Get SSH to keep a persistent master connection open in the background for a specific host. Future SSH commands to that server will then just “piggyback” on the existing connection, making them almost instant. It absolutely cuts out all the connection setup lag and saves you headaches.
# Add this to your ~/.ssh/config file:
Host *
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h:%p
ControlPersist 5m
⚙️ Why It Works
`ControlMaster auto` tells your SSH client to try and create or reuse a master connection. The `ControlPath` specifies the local socket file that’ll be used for this. And `ControlPersist 5m` keeps that master connection alive for five minutes after you close your last terminal session to the host, ready for your next command.
🚀 Pro-Tip: If you’re hammering a specific dev server all day, set `ControlPersist yes` for that specific `Host` block.
Linux Tips & Tricks | © ngelinux.com | 9/25/2026
