SSH "Too many authentication failures"
Why an SSH server ends the login with "Too many authentication failures", how MaxAuthTries counts attempts, and how IdentitiesOnly fixes it.
Received disconnect from 192.0.2.10 port 22:2: Too many authentication failures
Disconnected from 192.0.2.10 port 22
The server sent this and closed the connection, because the number of failed login attempts in one connection reached its limit. It is not a message from your client, and it does not mean the account is locked.
The limit
MaxAuthTries in the server's sshd_config sets how many authentication attempts one connection may make. The default is 6. The server logs "maximum authentication attempts exceeded" and disconnects when the failures reach that number.
Each failed attempt counts, so a client that tries several keys and then a password can reach 6 quickly. A wrong password counts as one.
Common cause: the client offers too many keys
An SSH client can offer every key it knows: keys loaded in an agent, and the default key files in ~/.ssh. The server rejects each key that does not match, and each rejection can count. With many keys, the limit can be reached before the client ever gets to the key the server would accept, or to the password prompt.
sshd allows a few "query" attempts for public keys, 6 by default, before they count as failures (the max-pk-ok option). After that, every extra key counts.
Fix it on the client by offering only the key you mean to use. In the OpenSSH client configuration (~/.ssh/config) on a computer, that looks like this:
Host example.com
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
IdentitiesOnly yes tells OpenSSH to use only the identity files named in the settings or on the command line, even if an agent offers more. On a command line you can give it as -o IdentitiesOnly=yes -i ~/.ssh/id_ed25519.
Other causes
- The wrong password or passphrase, repeated. The client asks for a password up to
NumberOfPasswordPromptstimes (3 by default), and each wrong one is a failed attempt on the server. - The key is not on the server, or it is in the wrong account. Then every key you offer fails, and you see "Permission denied (publickey)" first: see SSH problems.
- A server policy that allows fewer tries. Only the server's administrator can raise
MaxAuthTries. Write to them with the host name and the time of the attempt.
What to do
- Wait a moment and connect again. The count starts at zero on each new connection.
- Offer one key, as above.
- If it still fails, read the earlier lines of the failed attempt, or run
ssh -vand look at which keys were offered and refused. - If the host should accept your key, ask the administrator to check the account's
authorized_keysfile and thesshdlog.
Related
- The agent and agent forwarding
- The ssh config file
- SSH problems
- SSH error messages, what each one means
- sshd log "Received disconnect ... 11: Bye Bye" with preauth