VMHeaven

Troubleshooting

SSH: Too many authentication failures — the agent is the culprit

This error is usually not a wrong password — your SSH agent offered too many keys before the right one. Fix it with IdentitiesOnly and a clean agent.

Updated 08 Aug 2026~5 min read

Received disconnect … Too many authentication failures usually is not about a wrong password. It means your SSH client offered the server more keys than it allows per connection, and the server cut you off before you reached the one that works.

Why a client with one password fails this way

The SSH agent offers every key it has loaded, one at a time, before falling back to a password. sshd defaults to MaxAuthTries 6. Load seven keys in your agent and the server hangs up on the seventh attempt — the password prompt you were expecting never arrives.

how many keys is the agent offering?
ssh-add -l   # lists every key the agent will try

The fix: offer only the right key

IdentitiesOnly=yes tells the client to use only the key you name and stop spraying the agent’s whole collection:

one connection
ssh -o IdentitiesOnly=yes -i ~/.ssh/id_ed25519 user@host

Make it the default for that host in ~/.ssh/config:

~/.ssh/config
Host myserver
    HostName 203.0.113.10
    User ubuntu
    IdentityFile ~/.ssh/id_ed25519
    IdentitiesOnly yes

Or prune the agent

If you just want a clean slate, drop all loaded keys and add back only the one you need:

reset the agent
ssh-add -D              # remove all identities
ssh-add ~/.ssh/id_ed25519

Server side: raise the limit (carefully)

You can lift MaxAuthTries, but treat it as a last resort — a higher limit also gives brute-force attempts more room. Prefer fixing the client.

/etc/ssh/sshd_config
MaxAuthTries 10
# then
sudo sshd -t && sudo systemctl restart ssh

Confirm which key actually worked

verbose
ssh -v user@host 2>&1 | grep -Ei 'offering|accepted|authenticated'

Once you know the working key, pin it in ~/.ssh/config and the error will not come back. A fresh VPS with console access means that even a locked-out agent is never a dead end.

Frequently asked

Why does this happen when I only have one password?

Your SSH agent offers every loaded key before falling back to a password. If it offers more than the server's MaxAuthTries (default 6), you are disconnected before the password prompt.

What is the cleanest fix?

Add 'IdentitiesOnly yes' and the specific IdentityFile to that host in ~/.ssh/config, so the client offers only the one key that works.

Should I raise MaxAuthTries on the server?

Only as a last resort. A higher limit also gives brute-force attempts more room. Fix the client side first.

More in Troubleshooting

See all