- Select the key with -i and limit additional identities with IdentitiesOnly=yes.
- Use ssh -v to investigate attempts and ssh -G to review the effective configuration.
- Save a specific block per server and check that other rules do not add identities.
- Avoid emptying the entire agent or increasing server attempts as a first solution.
The mistake “Too many authentication failures” in SSH This indicates that the server has terminated the connection after reaching its authentication attempt limit. This message may appear before you enter a password if the client is attempting to authenticate with multiple identities.
A common cause is having multiple keys available in the SSH agent and not selecting the correct one for that server. To check this, explicitly specify the key, review the connection log, and save a specific configuration for the destination.
Connect by specifying the key and limiting the identities

If you know the password that account should use, try it from the client computer:
ssh -o IdentitiesOnly=yes -i ~/.ssh/id_ed25519_servidor [email protected]
Replace the example path with your identity file and change the username and server. If the connection uses a port other than the usual one, specify it using -p:
ssh -p 2222 -o IdentitiesOnly=yes -i ~/.ssh/id_ed25519_servidor [email protected]
The -i option selects the identity file. The adjustment IdentitiesOnly=yes It limits the use of additional identities that the agent may offer.
If it works, save the selection per server. If it continues to fail, check the actual configuration: there may be other identities added via SSH rules.
Why does the error appear before asking for the password?
The client may attempt to authenticate with keys before being offered other methods. If enough attempts are made, the server closes that connection before reaching the expected credentials.
The server parameter MaxAuthTries This controls the maximum number of attempts allowed per connection. Its documented default value is 6, although the administrator may have set a different value, and the handling of key offers depends on the OpenSSH version.
Therefore, the message does not prove that you have entered the password incorrectly multiple times. Nor does it, on its own, mean that the account or IP address is permanently blocked. Other security mechanisms may apply additional restrictions, but these require separate investigation.
During public key authentication, The private key is not sent to the server.The client demonstrates that they can use it through cryptographic operations.
Check which identities SSH is trying to use

Duck -v to obtain diagnostic information:
ssh -v -o IdentitiesOnly=yes -i ~/.ssh/id_ed25519_servidor [email protected]
Look for the lines that indicate which identities are offered and which methods the server accepts. If you need more detail, you can increase the verbosity with -vv o -vvv.
To review the identities loaded into the agent accessible from that terminal, run:
ssh-add -l
This command reveals its fingerprints. A warning that the agent has no identities is different from an error indicating that it cannot be contacted. Furthermore, the agent not having keys does not prevent the use of a key stored in a local file.
If you share the diagnosis with support, first double-check the usernames, servers, and paths that appear. Do not publish private keys or their protection passwords.
Save a specific configuration for each server.

In the client configuration file, normally ~/.ssh/configYou can define an alias with your identity:
Host servidor-trabajo
HostName servidor.example
User usuario
Port 22
IdentityFile ~/.ssh/id_ed25519_servidor
IdentitiesOnly yes
Then use the alias:
ssh servidor-trabajo
Adapt the name, port, and path. Maintain a distinct identity in each block when destinations require different keys.
You don't need to apply a global rule to all your connections to resolve a single server. Aliases allow you to check for changes with a more specific scope.
Check if other rules add keys
The directives IdentityFile They can accumulate between matching blocks and included files. Therefore, a general rule can also contribute identities to the destination.
View the resulting configuration without initiating a connection:
ssh -G servidor-trabajo
Check especially hostname, user, port, identitiesonly and the tickets identityfileThis helps detect differences between the block you've written and what the client will actually use.
Manage the agent without unnecessarily emptying it
If you identify a key that you no longer need in the agent, you can remove that specific identity using its public file:
ssh-add -d ~/.ssh/id_ed25519_antigua.pub
To load an identity available on disk:
ssh-add ~/.ssh/id_ed25519_servidor
There is also ssh-add -D, which removes all the agent's identities. It does not delete your files from the disk.However, other new connections that depend on that agent may stop authenticating until you reload them.
Therefore, selecting the identity by destination is usually more practical than emptying the agent each time. If a key manager reloads identities, review its configuration before repeating the cleanup.
What to check if you use Ansible

If the manual connection works but Ansible fails, compare the user, destination, key, and connection arguments. It's not enough to assume that the automation uses the same configuration as your test.
With the SSH connection plugin, you can add arguments using ansible_ssh_common_argsIf jump or proxy options already exist, keep them and add the necessary selection.
For a one-off test with existing inventory:
ansible servidor-trabajo -m ansible.builtin.ping --private-key ~/.ssh/id_ed25519_servidor --ssh-common-args='-o IdentitiesOnly=yes'
Adapt the host to the name used in your inventory. The test also depends on the module requirements and the remote machine; its result is not limited to verifying authentication.
If the server continues to reject the connection
If you have already restricted identities and access continues to fail, check that the user is correct and that their account has the corresponding public key authorized.
A key routing error, a rejected credential, and too many attempts are different problems. Detailed logging allows you to distinguish between them. If you manage the server, also review its authentication logs; otherwise, provide the administrator with the necessary information for diagnosis.
Increasing MaxAuthTries should not be the first measure when the source is an incorrect selection of identities on the client. It is also not necessary to delete known_hosts or disable server identity verification: those options belong to a different phase of the connection.
Once resolved, open a new connection using the alias and confirm that it uses the expected identity. This will give you a reusable configuration without needing to clear the agent before each access.
Index
- 1 Connect by specifying the key and limiting the identities
- 2 Why does the error appear before asking for the password?
- 3 Check which identities SSH is trying to use
- 4 Save a specific configuration for each server.
- 5 Manage the agent without unnecessarily emptying it
- 6 What to check if you use Ansible
- 7 If the server continues to reject the connection