The Linux Page

Too many authentication failures for <username>

Today I tried to make use of sftp to transfer a website to SourceForge.net. Unfortunately, it kept giving me an error:

Received disconnect from <IP address>: 2: Too many authentication failures for <username>

I looked around why that would happen and could not really find anything decisive... until I found an issue in the trac system that SourceForge.net uses. That issue mentioned the fact that the ssh-agent could be the culprit.

It was. Somehow the ssh-agent was sending key after key after key... exhausting the number of keys that SourceForget.net will accept and thus made it fail before I could enter a password which was the next option.

To resolve the problem, I could stop the ssh-agent. Annoying if I have to do it each time. Instead, I edited my ~/.ssh/ssh_config file and use the option that tells SSH to not use the ssh-agent:

Host sfweb
  HostName web.sourceforge.net
  User <username>
  PasswordAuthentication yes
  HostbasedAuthentication no
  IdentitiesOnly yes

The important option is the IdentitiesOnly. When set to no it checks whether ssh-agent is running.