Small Printed Circuit Board

Code, Docs & Tools

LFTP: how to fix the "Fatal error: Host key verification failed" error

LFTP "Fatal error: Host key verification failed" error

It could happen that trying to connect to a server using the sftp protocol with LFTP, you receive the error "Fatal error: Host key verification failed".

$ lftp sftp://user@1.2.3.4:21 Password: lftp user@1.2.3.4:~> ls ls: Fatal error: Host key verification failed

The cause of the problem is the missing RSA key fingerprint in the list of known hosts.

To fix it, it's enough to try to connect to the SFTP server using the ssh command:

$ ssh -p 21 user@1.2.3.4 The authenticity of host '[1.2.3.4]:21 ([1.2.3.4]:21)' can't be established. RSA key fingerprint is 01:23:45:67:89:ab:cd:ef:01:23:45:67:89:ab:cd:ef. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '[1.2.3.4]:21' (RSA) to the list of known hosts. user@1.2.3.4's password:

Once it asks the password, you can just interrupt the program pressing CTRL+C.

Now you can successfully connect to the SFTP server:

$ lftp sftp://user@1.2.3.4:21 Password: lftp user@1.2.3.4:~> ls drwx------ user/user 4096 2017-07-31 16:41:35 . drwx------ user/user 4096 2017-07-31 16:41:35 .. -rw------- user/user 3274 2017-09-08 23:47:02 file1 drwx------ user/user 4096 2017-07-31 16:41:35 file2 lftp user@1.2.3.4:/> quit

Bye.