SFTP Connection Error – Fixing ‘500 Syntax Error, Command Unrecognized’

ftpsftpUbuntu

I've been trying to connect to an FTP server using sftp. The connection closes with 500 Syntax error, command unrecognized:

...
debug1: ssh_exchange_identification: 220-Welcome To FTP Server

debug1: ssh_exchange_identification: 220-....

debug1: ssh_exchange_identification: 220 ....

debug1: ssh_exchange_identification: 500 Syntax error, command unrecognized

debug1: ssh_exchange_identification: 421 Login time exceeded. Closing control connection.

ssh_exchange_identification: Connection closed by remote host

Screenshot of the complete verbose output

Was wondering what will be the possible error and what the fix would be.

Best Answer

The welcome message is an FTP thing. The same with "500 Syntax error, command unrecognized" – That's an FTP error message. There's nothing like that in the SFTP protocol.

Their server responds with FTP protocol on the SSH/SFTP 22 port. It can also be FTPS vs. SFTP confusion. The FTPS is secure extension of the FTP. While the SFTP is different thing.


You cannot connect to an FTP server using an SFTP client. The FTP and SFTP are two completely different protocols. Use an FTP client, like the common Linux commandline ftp.

As the FTP server listens on a non-standard port (22), you have to do something like:

$ ftp
ftp> open example.com 22