Received disconnect from 203.0.113.10 port 22:2: Too many authentication failures
Disconnected from 203.0.113.10 port 22This happens when you have more keys than the server allows attempts. OpenSSH servers allow MaxAuthTries 6 by default. Your client offers keys one at a time, from your config first and then everything loaded in ssh-agent, and each rejected key uses up one attempt. With five or six keys in the agent, the right one may never get its turn.
#Confirm it
ssh -v user@server.example.com 2>&1 | grep -c "Offering public key"If that number is 5 or more, this is your problem. Also check what the agent is carrying:
ssh-add -l#Fix 1: offer only the right key (best)
Tell SSH which key belongs to this server and to ignore the rest:
Host server.example.com
User deploy
IdentityFile ~/.ssh/deploy_ed25519
IdentitiesOnly yesIdentitiesOnly yes limits SSH to the files named in your config (and on the command line), even if the agent holds more. Now the server sees one attempt, and it's the right one. More detail: IdentitiesOnly explained.
For a one-off connection without editing the config:
ssh -o IdentitiesOnly=yes -i ~/.ssh/deploy_ed25519 deploy@server.example.com#Fix 2: stop a wildcard from adding keys everywhere
IdentityFile adds up across every matching Host block. A Host * with its own key adds that key to every connection, on top of the specific one:
Host server.example.com
IdentityFile ~/.ssh/deploy_ed25519
IdentitiesOnly yes
Host * !server.example.com
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yesThe !server.example.com exclusion keeps the default key off that host. See SSH wildcards and precedence.
#Fix 3: slim down ssh-agent
If you've added many keys over time, clear the agent:
ssh-add -D # removes all identities from the agent (key files are untouched)On a Mac with AddKeysToAgent yes and UseKeychain yes, keys come back automatically the next time a host uses them.
#What about raising MaxAuthTries?
If you control the server, you can raise MaxAuthTries in /etc/ssh/sshd_config. But that hides the real issue (an unspecific client config) and gives attackers more guesses per connection. Fix the client instead.
#Make it impossible
The root cause is a config that doesn't say which key goes with which host. EasySSHConfig writes one Host rule per address with IdentitiesOnly yes, orders them so the most specific address wins, and warns you when your own config still offers extra keys to a host.
Frequently asked questions
What is the default MaxAuthTries in OpenSSH?
Six attempts per connection. Every key your client offers counts as one attempt, so a seventh key is never tried.
Is it safe to raise MaxAuthTries on the server?
It works, but it treats the symptom. The better fix is on the client: offer only the key that belongs to that server with IdentityFile and IdentitiesOnly yes.
Will ssh-add -D delete my keys?
No. It only removes identities from the running ssh-agent. Your key files in ~/.ssh are untouched, and keys load again when you next use them if AddKeysToAgent is on.