Article Image

Not long ago, I was trying to login to a new server and I was continually met with the error:

ssh X.X.X.X
Received disconnect from X.X.X.X: 2: Too many authentication failures for [username]

After ensuring that I wasn't the issue and that the server wasn't to blame, I asked my friend Google what could be happening.

This is what was happening. When you give the command ssh x.x.x.x, SSH tries to authenticate with that server using each one of your private keys before even presenting you with the option for interactive password authentication. This is the default behaviour - and I'm OK with that now that I know, but it is a bit quirky.

For this particular server, I did not have a key - I needed to use a password to authenticate. To stop the SSH client from attempting key based authentication, you can do one of two things:

  1. Pass a flag at connection time - -o PubkeyAuthentication=no.
  2. In your SSH config add the PreferredAuthentications password option for that host.

Also - if you ever run into issues with SSH, run it with -v (or -vv) and see what SSH is really doing behind the scenes.

Blog Logo

Jon Dowdle

Jon Dowdle currently works on the internet at a lovely place called InVision.



Jon Dowdle's Blog

The personal blog of Jon Dowdle.

Back to Overview