SSH & Remote Administration
Reuse your SSH connections for blazing speed
đ§© The Challenge
Ever jump between a bunch of servers, and every single SSH connection feels like it takes forever to set up? You type your alias, hit Enter, and then wait⊠wait for the handshake, the key exchange, authentication, sometimes even MFA prompts. Itâs a drag, especially when youâre just dropping in to grep a log file or check a service status on multiple boxes. Drives me absolutely bonkers.
đĄ The Fix
Thereâs a simple SSH config trick thatâll make all subsequent connections to the *same host* almost instant. It reuses the first connection you make, so you only pay that initial overhead once. Saves a ton of time throughout the day when youâre jumping around.
# Add this to your ~/.ssh/config file:
Host *
ControlMaster auto
ControlPath ~/.ssh/cm_sockets/%r@%h:%p
ControlPersist 5m
# You'll also need to create the directory for the sockets if it doesn't exist:
mkdir -p ~/.ssh/cm_sockets
âïž Why It Works
This tells SSH to try and reuse an existing connection (ControlMaster auto). If one isnât found, it establishes a new connection and makes it the âmaster.â All subsequent connections for that host then use the socket specified by ControlPath to piggyback on the master. ControlPersist keeps that master connection open in the background for a set time, even after you disconnect your last client.
đ Pro-Tip: Set ControlPersist to ânoâ or a very short duration if youâre connecting from untrusted systems or shared jump boxes. Donât want lingering connections hanging around.
Linux Tips & Tricks | © ngelinux.com | 11/3/2026
