Too many authentication failures in SSH almost never means a wrong password. Your SSH client offered the server every key it has. The server stops counting after a few tries and drops the connection before the right key ever gets a turn. Here is the one-line fix:
bashssh -o IdentitiesOnly=yes -i ~/.ssh/your_key user@your-server
That tells SSH to use only the key you name, so it gets in on the first try.
Quick Answer:
- Log in with a key:
ssh -o IdentitiesOnly=yes -i ~/.ssh/your_key user@host- Log in with a password:
ssh -o PubkeyAuthentication=no user@host- Make it permanent: add
IdentitiesOnly yesand anIdentityFileline for that host in~/.ssh/config(see below)- Why it happens: your ssh-agent holds more keys than the server's
MaxAuthTrieslimit (6 by default), and every key it offers counts as a failed attempt
What the Error Looks Like
You will usually see one of these, straight after you run ssh:
textReceived disconnect from 203.0.113.10 port 22:2: Too many authentication failures Disconnected from 203.0.113.10 port 22
Older clients print Too many authentication failures for root instead. The message comes from the server. It hung up because your client used up the allowed attempts.
Why SSH Says Too Many Authentication Failures
When you connect, your SSH client does not know which key the server expects. So it offers keys one at a time:
- Every key loaded in your
ssh-agent - The default files:
~/.ssh/id_ed25519,~/.ssh/id_rsa,~/.ssh/id_ecdsa - Any
IdentityFileset in your config
The OpenSSH server allows 6 authentication attempts per connection by default (the MaxAuthTries setting), and each rejected key uses one. Load seven keys for seven different servers, and the right key may come eighth. The connection is closed before the client ever reaches it, and before you even get a password prompt.
This is why the error appears "suddenly". Nothing on the server changed. You just added one more key to your agent — a new GitHub key, a client's server or a work laptop key — and pushed the right one past the limit.
Confirm it in 10 seconds
Run SSH in verbose mode and count the offered keys:
bashssh -v user@your-server 2>&1 | grep -E "Offering|Authentications that can continue"
If you see five or six Offering public key lines before the disconnect, this is your problem. Then list what your agent is holding:
bashssh-add -l
More than five keys listed? That is almost certainly the cause.
Fix 1: Tell SSH Exactly Which Key to Use
This is the right fix for almost everyone. It works immediately and changes nothing on the server.
bashssh -o IdentitiesOnly=yes -i ~/.ssh/client_server_key [email protected]
-ipoints to the private key for this serverIdentitiesOnly=yesstops SSH from also offering every agent key first
Without IdentitiesOnly=yes, SSH still offers all agent keys before the one you named with -i, so -i alone often does not fix it.
Fix 2: Log In With a Password Instead
If the server uses password login and you have no key for it, turn key login off for this one connection:
bashssh -o PubkeyAuthentication=no user@your-server
You will get the password prompt straight away. If the server answers Permission denied (publickey), password login is turned off on that server, and you need the right key or console access from your provider.
Still working through this server issue?
Send the symptoms, error output, and what you have already tried. We can work with Hostaccent services or infrastructure hosted with another provider.
Fix 3: Make It Permanent in ~/.ssh/config
Typing flags every time gets old. Give each server its own entry in ~/.ssh/config:
textHost myvps HostName 203.0.113.10 User deploy Port 22 IdentityFile ~/.ssh/myvps_ed25519 IdentitiesOnly yes
Now just run:
bashssh myvps
SSH offers only myvps_ed25519 and connects first time. Add one block per server. If you moved SSH off port 22, put the new number on the Port line — our guide to changing the SSH port safely covers that.
Pro Tip: Do not put
IdentitiesOnly yesunderHost *unless every server has its ownIdentityFileline. Otherwise servers that relied on your agent keys will stop working.
On Windows, the same file lives at C:\Users\YourName\.ssh\config and works the same way with the built-in OpenSSH client.
Fix 4: Clean Up Your ssh-agent
If your agent has collected keys you no longer need, clear them:
bashssh-add -D # remove all keys from the agent ssh-add ~/.ssh/id_ed25519 # add back only the one you use most
ssh-add -D only unloads keys from memory. It does not delete your key files.
Password managers that act as SSH agents (1Password, Bitwarden, KeePassXC) can hold dozens of keys. Either limit which keys the agent offers in its settings, or rely on IdentitiesOnly yes per host.
Fix It for Git, SCP, rsync and Deploy Tools
The same error breaks anything that uses SSH underneath.
Git:
bashGIT_SSH_COMMAND="ssh -o IdentitiesOnly=yes -i ~/.ssh/github_key" git pull
Or set it once for a single repository:
bashgit config core.sshCommand "ssh -o IdentitiesOnly=yes -i ~/.ssh/github_key"
scp and rsync:
bashscp -o IdentitiesOnly=yes -i ~/.ssh/myvps_ed25519 backup.tar.gz [email protected]:~ rsync -av -e "ssh -o IdentitiesOnly=yes -i ~/.ssh/myvps_ed25519" ./site/ [email protected]:~/site/
If you set up a Host block as in Fix 3, all of these tools use it automatically — just use the alias, like scp file myvps:~.
Should You Raise MaxAuthTries on the Server?
Only if you control the server and have a good reason. Check the current value:
bashsudo sshd -T | grep -i maxauthtries
You can raise it in /etc/ssh/sshd_config and reload SSH, but it is the wrong fix. A higher limit gives password-guessing bots more attempts on every connection. Fix the client instead and keep the default (6) or lower.
If you are getting disconnected even with the right key, the cause is different. Look at SSH connection refused and SSH connection timed out for firewall and port problems. Also check whether a tool like Fail2ban banned your IP after too many failed attempts.
Still Locked Out?
If none of the fixes work and you cannot reach the server at all, use your provider's web console (VNC or serial console). It logs you in without SSH keys, so you can check ~/.ssh/authorized_keys and the SSH service directly. On a Hostaccent VPS, the console is in the client area. Our 24/7 support team can also check the server side for you.
New to SSH keys? Start with what SSH is and how key login works.
Frequently Asked Questions About Too Many Authentication Failures SSH
Does "too many authentication failures" mean my password is wrong?
Usually not. In most cases your client offered too many keys before it even reached the password prompt. Run ssh -v and look for repeated Offering public key lines to confirm.
What is the default MaxAuthTries in OpenSSH?
Six. Once half of that is used up, the server also starts logging the failures. Each key your client offers and the server rejects counts as one attempt.
Will ssh-add -D delete my SSH keys?
No. It only removes keys from the running agent's memory. Your key files in ~/.ssh/ stay untouched, and you can load them again with ssh-add.
Why does it work with -i on one computer but not another?
The other computer's agent probably holds more keys. -i adds your key to the list but does not stop the agent keys being offered first. Add -o IdentitiesOnly=yes.
Is it safe to increase MaxAuthTries?
It works, but it weakens protection against brute-force attacks. Limiting the keys your client offers with IdentitiesOnly yes is the safer fix.
Can this happen with GitHub or GitLab?
Yes. The fix is the same: point Git at the right key with core.sshCommand or a Host github.com block that sets IdentityFile and IdentitiesOnly yes.











Discussion
Have a question or tip about this topic? Share it below — your comment will appear after review.