“Failed to load HostKeys” warning while connecting to SFTP server with pysftp

I believe it’s a bug in pysftp. You get this everytime you use cnopts.hostkeys = None (despite the warning actually suggesting to use that).

Anyway, you should not use cnopts.hostkeys = None, you lose security by doing so.
For the correct solution, see Verify host key with pysftp.


By your reference to key authentication, I assume you mistake your account key with host key.
Read my article about SSH key pairs to understand the difference.

Leave a Comment