SSH: Too many authentication failures

I was trying to connect to a server at SiteGround that I had connected to hundreds of times before, but suddenly, my key wasn’t working. I just kept getting the error message “Too many authentication failures”.My first thought was that my IP address was being blocked or disallowed (maybe it had changed since the last time I logged in) by the hosting company. I tested connecting with two other accounts with the same company, and one worked fine and the other one was also getting this same error.

Then, I checked the admin panel for the server to see if there were an IP address allow list for SSH connections. I could not find anything there, so I contacted SiteGround’s help desk, and they confirmed that my IP address was not being blocked by them.

Next, I thought maybe something had happened with my key. I generated completely new keys and installed them. No luck. Still got the same error message.

I started researching, and I discovered that this error oftentimes means that the server is receiving too many keys from your local machine. This seemed odd to me as I have it configured to use a specific key. I ran the ssh connection command with the -v flag so I could see more about what was going on:

ssh <connection_string> -v

Sure enough, my computer was sending the preferred key first (or so it appeared) but was also sending a bunch of other keys. I had no idea why the config file was not seeming to work as I expected it to, so I did some more digging.

Finally, I ran across an article talking about the IdentitiesOnly property for SSH. This can be set on the command line, but since I was already using the config file, I figured it would be good to keep everything in one place. I added the declaration to the top of my config file in the default section I already had in place. It now looked like this:

Host *
  IdentitiesOnly=yes

After saving and closing my config file, I tried again to connect and this time, everything worked! Everything had always worked previously because I just happened to not have enough keys to trigger the issue. Between my previous connection to this server and now, I had just happened to add enough keys to start causing issues on some servers.

Here is a link to the article I found on IdentitiesOnly that finally solved my issue:
How to Fix “SSH Too Many Authentication Failures” Error

 

Leave a Reply

Your email address will not be published. Required fields are marked *