How to fix "Received disconnect: Too many authentication failures"

Tested: we reproduced this error and confirmed the fix on Ubuntu 24.04 with OpenSSH 9.6p1, client and server, November 29, 2026.

Your SSH client offered more keys than the server allows before it reached the right one, so the server disconnected. This happens when your SSH agent (or a password manager acting as one) holds many keys. Tell SSH which key to use and to offer only that one:

ssh -o IdentitiesOnly=yes -i ~/.ssh/your_key user@server

We reproduced it with OpenSSH 9.6: with eight keys loaded in ssh-agent and the correct one added last, the server stopped after six attempts. The same command with IdentitiesOnly=yes -i connected straight away.

What the error looks like

Received disconnect from 127.0.0.1 port 2223:2: Too many authentication failures
Disconnected from 127.0.0.1 port 2223

Count what SSH tried with -v:

ssh -v user@server 2>&1 | grep "Offering public key"

In our test that printed six Offering public key lines, matching OpenSSH’s default MaxAuthTries 6, before the disconnect.

Fix it for good in ~/.ssh/config

Give the server its key once and SSH stops trying the others:

Host myserver
  HostName server.example.com
  User ubuntu
  IdentityFile ~/.ssh/your_key
  IdentitiesOnly yes

IdentitiesOnly yes is the important line: without it, SSH still offers every key in the agent first. You can also put it under Host * so it applies to every server you’ve configured with an IdentityFile. Our SSH config file guide covers the rest of the file.

Other fixes

  • Trim the agent. ssh-add -l lists loaded keys and ssh-add -D removes them all; add back only what you use. Password managers that act as an SSH agent can hold many keys too, so check their SSH settings if you use one.
  • Go straight to the password. If the server uses passwords: ssh -o PubkeyAuthentication=no user@server.
  • On the server, MaxAuthTries in /etc/ssh/sshd_config sets the limit. Raising it works but weakens protection against guessing.

Confirm it worked

The connection succeeds, and ssh -v shows a single Offering public key line followed by Authenticated to ... using "publickey", as it did in our test. If you now get Permission denied (publickey) instead, SSH is offering only one key and it’s the wrong one: see our fix for that error.

FAQ

How do I reset the too many authentication failures error?

There's nothing to reset: the limit applies to each connection attempt, and the next attempt starts again at zero. Change what your client offers (IdentitiesOnly yes with the right IdentityFile) and connect again. Tools like fail2ban on the server are different and may block your IP for a while after repeated failures.

Should I raise MaxAuthTries on the server?

Only if you control the server and have a reason. It's a limit on guessing; the cleaner fix is a client that offers the right key first. IdentitiesOnly yes in ~/.ssh/config fixes it for every server at once.

Why does it happen with password login too?

SSH tries your keys before asking for a password. If it uses up the attempts on keys, the server disconnects before the password prompt. Use -o PubkeyAuthentication=no to go straight to the password.

How many attempts does a server allow?

OpenSSH's default MaxAuthTries is 6. Servers can set it lower.