Programster's Blog

Tutorials focusing on Linux, programming, and open-source

FileZIlla - Fix SFTP Protocol Error - Too Many Authentication Failures

The Problem

I had just set up a fresh user account on my Ubuntu server for a client, and was testing the connection in FileZilla (using SFTP) when I was getting the following error.

The text is below for SEO, so that other people experiencing this issue may find this post.

Status: Connecting to XXX.XXX.XXX.XXX...
Response:   fzSftp started, protocol_version=9
Command:    open "myUsername@XXX.XXX.XXX.XXX" 22
Error:  FATAL ERROR: Remote side sent disconnect message
Error:  type 2 (protocol error):
Error:  "Too many authentication failures"
Error:  Could not connect to server

The Solution

It turns out that even though I had set FileZilla to use a password, it was trying the keys inside my $HOME/.ssh directory. After it had tried and failed with enough of these, it bails out with "too many authentication failures". One Stack Overflow post suggested keeping no more than 4 keys in there. However, I found the easier solution was to just set the SSH_AUTH_SOCK to null before running filezilla, like so:

SSH_AUTH_SOCK=null filezilla &

As this forum post explains:

This sets the SSH_AUTH_SOCK shell environment variable only for this instance of filezilla, which means any other program (e.g. ssh) can still use the agent while filezilla wont be able to do so.

Last updated: 17th March 2022
First published: 17th March 2022