Console9

SSH: Too many authentication failures

Diagnose and fix 'Too many authentication failures' when the SSH agent offers too many keys before the correct one.

SSH produces "Received disconnect: Too many authentication failures" when the client offers more keys than the server's MaxAuthTries limit before presenting the correct one.

When SSH Produces This Error

SSH displays this error when the SSH agent ( ssh-agent) holds many keys and offers them sequentially. The server allows a maximum number of authentication attempts (default: 6 in OpenSSH). If the correct key is not among the first 6 offered, the server disconnects.

What Causes "Too many authentication failures" in SSH

The SSH agent has too many keys loaded. Each loaded key counts as one authentication attempt. With 8 keys loaded, the server rejects the connection before the agent reaches the correct key.

How to Fix "Too many authentication failures" in SSH

  1. Specify the correct key explicitly, bypassing the agent's key list:
ssh -o IdentitiesOnly=yes -i ~/.ssh/correct_key user@203.0.113.50
  1. Alternatively, remove unnecessary keys from the SSH agent:
ssh-add -D
ssh-add ~/.ssh/correct_key
  1. Set IdentitiesOnly yes in the SSH config file for the affected host:
Host production
    HostName 203.0.113.50
    User admin
    IdentityFile ~/.ssh/prod_key
    IdentitiesOnly yes

How to Verify the Fix

SSH connects without the "Too many authentication failures" error.

SSH: Permission denied (publickey)— the correct key is offered but rejected.