Stop your SSH session from cluttering your home directory with control sockets
SSH & Remote Administration
Stop your SSH session from cluttering your home directory with control sockets
🧩 The Challenge
You ever realize your ~/.ssh folder is filled with ancient, lingering control sockets because you forgot to close a session properly? It’s a mess and it makes finding your actual config files a chore.
💡 The Fix
Use a dedicated, temporary directory for your multiplexing sockets so they don’t clutter up your main configuration space and delete themselves when you’re done.
Host *
ControlPath ~/.ssh/sockets/ssh-%r@%h:%p
ControlMaster auto
ControlPersist 10m
⚙️ Why It Works
Setting the ControlPath to a specific directory ensures all your mux sockets live in one organized spot. Making sure that directory actually exists is the key, otherwise, SSH just fails silently like it usually does.
🚀 Pro-Tip: Stick a mkdir -p ~/.ssh/sockets in your dotfiles setup script so you don’t have to think about it when you move to a new machine.
Linux Tips & Tricks | © ngelinux.com | 8/6/2026
