SSH returns “too many authentication failures” error – HostGator

I am an avid fan of using HostGator for small business WordPress website hosting. I love that they use a standard CPanel installation and I can get SSH access, it’s quick and easy – a diet VPS/dedicated server if you will.

I have been having an issue I’ve never seen before, when attempting to connect, e.g.:

ssh -p 2222 username@12.34.56.78

I was receiving the following error:

Received disconnect from 12.34.56.78: 2: Too many authentication failures for username

Why I Got This Too Many Authentication Failures Error

Recently, I started working on a large project that involved two big brands, in working with their dev team, I started using Git (which I love now) and authenticating with SSH keys.

After a few hours back and forth with support, troubleshooting IP blacklists and user errors, we realized it was key conflict that was troubling things. I temporarily moved these keys out of the ~/.ssh/ directory and I was okay – until I reset them and they were stored in my OS X keychain.

Even moving them or deleting them did nothing. I also want to keep these keys intact because I use them to authenticate with Git and some of my project servers.

How I Fixed It

Thanks to this answer on superuser.com, I realized there’s a nice little flag for options I can send: -o PubkeyAuthentication=no.

By using this flag, I can have the connection disregard public key authentication all together and allow me to go straight to user/pass login. The final command:

ssh -p 2222 -o PubkeyAuthentication=no username@12.34.56.78

Note: the -p 2222 is only required for HostGator in this case, as SSH is restricted to port 2222. Feel free to remove or modify the port flag to your liking – I hope this helps you!

14 Comments

  1. Winton DeShong says…

    Thanks for the write up! Worked like a charm!

  2. Sheldon Kreger says…

    Yes, this worked very well on my shared HostGator account!

  3. Cody Erekson says…

    Exactly what I was looking for. Thanks a ton!

  4. Kurt says…

    Do you have to enter the option every time you want to open a connection? Or can it be set in a config file somewhere on hostgator’s side?

  5. theandystratton says…

    @Kurt I’m not sure, I have it committed to memory for all my HostGator clients.

    If I figure this out later, I will post a solution for sure.

  6. gProjecten says…

    Exactly what I was looking for. Great!

  7. Matt says…

    This did the truck for me, thank you!!

    Also I found that the same explanation and same solution are valid when having the same problem with scp, like so:

    scp -o PubkeyAuthentication=no -P 2222 filename.txt username@example.com:/home/username/public_html/domain-example-com/

  8. cww says…

    Thanks so much! This like was provided to my by Hostgator support and I am so happy to finally understand the issue.

  9. Tak says…

    FWIW: I had the same issue with Hostgator for the last two days and found the same link of Superuser.

    While your solutions works, it wasn’t the most elegant one. There’s another solution in the same thread:

    In your ssh config file: ~/.ssh/config
    add: “IdentitiesOnly yes”

    Host http://www.somehost.com
    IdentityFile ~/.ssh/key_for_somehost_rsa
    IdentitiesOnly yes
    Port 22

    Then If using the ssh-agent, run ssh-add -D to clear identities.

  10. Andy says…

    @tak this eliminates the need for the manual removal of the PubKey authentication? Looks like your specifying a key for a domain.

    I’m not a sysadmin by any means, so I’m not 100% certain here. Would love more input/feedback on your solution.

  11. Chichi Latté says…

    Thank you, you stopped me from going bald with frustration. Not that bald is bad, ask Larry David.

  12. TheBenO says…

    What about to try:
    ssh -o ‘GSSAPIAuthentication no’

  13. Ed says…

    Good advice! It helped, thank you

  14. Dan says…

    Thanks, I was just about to chat with support. Funny though the reason.

RSS feed for comments on this post. TrackBack URL

Leave a Comment

July 9, 2012

Filed in Development, Terminal

There are 14 comments »


« Back to the Blog