Stop hitting your head against the wall when SSH keys aren’t being picked up
SSH & Remote Administration
Stop hitting your head against the wall when SSH keys aren’t being picked up
🧩 The Challenge
You’ve just spent twenty minutes carefully setting up your new laptop, adding your key to the ssh-agent, and confirming it with ssh-add -l, yet the remote server keeps asking for your password like you’re some kind of amateur. It’s infuriating when you know the key is right there but the agent refuses to hand it over to the handshake process.
💡 The Fix
Most of the time your local SSH config is just plain ignoring the agent or the agent environment variables are dangling in a different session window. Telling the client to explicitly request specific keys from the agent solves the dance before it starts.
ssh -o IdentitiesOnly=yes -i ~/.ssh/id_rsa user@remote-host
⚙️ Why It Works
Setting IdentitiesOnly to yes tells your SSH client to ignore any keys that aren’t explicitly configured in your ssh_config or via the command line, effectively forcing it to talk to the agent instead of scanning your entire home directory and getting distracted by random files. It stops the client from offering up every single identity it finds, which triggers rate limiting or lockout behaviors on some strict SSH daemons.
🚀 Pro-Tip: Add IdentitiesOnly yes to your ~/.ssh/config file under the Host * block so you never have to think about it again.
Linux Tips & Tricks | © ngelinux.com | 9/21/2026
