Symptoms & scope
- SSH disconnects with too many authentication failures.
- The intended key is listed after several other identities.
Relevant environment
OpenSSH client with ssh-agent or a key provider; connection-free configuration inspection.
Recognizable messages (synthetic examples)
sshd[921]: maximum authentication attempts exceeded for example from 192.0.2.10 port 50121 ssh2A key-selection problem is one possibility; the server line does not identify which method consumed the attempts.
Possible causes
These are possible explanations, not a confirmed diagnosis. Several independent faults can coexist.
- The agent may offer unrelated keys before the authorized one.
- Repeated password or keyboard-interactive failures may consume the same limit.
Diagnose safely
Run one command at a time in the relevant session. Read the explanation first. Uppercase placeholders need your own values; tools and privileges vary by distribution. These commands are displayed here and never executed by the website.
Check 1
Lists fingerprints from the current agent; it does not print private keys or change the agent.
ssh-add -lInterpret the result: A long list supports an identity-order issue. An agent connection error or an empty agent suggests a different authentication path.
Check 2
Replace HOSTNAME with the failing SSH alias. -G expands configuration without connecting.
ssh -G HOSTNAMEInterpret the result: Inspect identityfile, identitiesonly, identityagent and preferredauthentications; several IdentityFile entries remain eligible even with IdentitiesOnly.
Evidence-guided next steps
Select the intended identity for this host
If unrelated agent keys are the issue, use a host-specific IdentityFile and IdentitiesOnly yes. Test the same selection with ssh -o IdentitiesOnly=yes -i /path/to/key HOSTNAME. The command attempts a login; do not place it in unattended diagnostics.
Precautions: Use the existing private-key path; never paste key contents. Avoid changing defaults for every host.
Recovery / rollback: Remove the new host-specific options or restore the saved SSH configuration; a one-time command needs no file rollback.
Did this solution help you?
Correct the account or authentication method
If the agent is not responsible, verify the username and the required authentication sequence with the server administrator. Use the authorized key/account pair or complete the required second factor rather than retrying passwords against an exhausted limit.
Precautions: Do not increase MaxAuthTries globally to accommodate an unbounded agent list.
Recovery / rollback: Restore the previous username or authentication-method setting if a host-specific change was incorrect.
Did this solution help you?
References & review
This guide was prepared from primary project or distribution sources and reviewed on the date shown. This is an editorial source check, not evidence that a fix was reproduced on your hardware. Diagnostic log examples are synthetic fixtures. Version-dependent details must be checked against your installed release.
- OpenSSH ssh-add: list identities (project or distribution documentation)
- OpenSSH ssh_config: identity selection and host verification (project or distribution documentation)
- OpenSSH auth.c: authentication attempt limit (upstream implementation; behavior can vary by version)