Skip to content

How to fix ‘SSH too many authentication failures’ error?

  • by
  • 2 min read

Connecting to a remote machine via SSH is simple, easy and gets pretty much everything you’d need to do over a remote connection done. However, it’s not always as seamless as entering a command in the terminal and hitting enter to connect.

At times users may not able be able to connect to a remote client via SSH and get an “SSH too many authentication failures” error instead. In this article, we’re going over what this error is and how you can get rid of this.

Also read: What is SFTP? How to transfer files using SFTP?

What causes the ‘SSH too many authentication failures’ error?

This error is caused by inadvertently having way too many SSH keys in the ssh-agent file. When attempting to connect to an SSH client, the remote server would try all the keys, and if it doesn’t find the particular identity key it needs, it throws this error.

If the server is being offered too many keys, it’ll reject any key after too many tries. You can check this for yourself by adding the -v flag in your SSH command to get verbose output and check just how many keys are being offered.

How to fix the ‘SSH too many authentication failures’ issue?

To fix this problem, you have to prevent irrelevant keys from being offered to the server. We’re going to have to explicitly specify this in every host entry in the SSH configuration on the client machine by adding IdentitiesOnly for the host connection.

Step 1: Open the SSH configuration file using the command below.

vim ~/.ssh/config
How to fix 'SSH too many authentication failures' error?

Step 2: Add the following line under the Hosts* section of the file.

How to fix 'SSH too many authentication failures' error?

Alternatively, you can also mention this in the SSH command like this.

ssh -o IdentitiesOnly=yes server@111.222.333.444

Also read: How to enable SSH on Ubuntu?


Yadullah Abidi

Yadullah is a Computer Science graduate who writes/edits/shoots/codes all things cybersecurity, gaming, and tech hardware. When he's not, he streams himself racing virtual cars. He's been writing and reporting on tech and cybersecurity with websites like Candid.Technology and MakeUseOf since 2018. You can contact him here: