python - Failed to load HostKeys from directory - pysftp ...
stackoverflow.com › questions › 64057109Sep 25, 2020 · You are mixing two unrelated problems/keys. See Understanding SSH key pairs. You are adding your user private key to the list of host public keys (aka hostkeys): cnopts.hostkeys.add(secrets.FTP_SERVER, 'ssh-rsa', priv_key_path) So 1) "setting cnopts.hostkeys = None" and 2) "changing the format of the key to PEM" solve two different problems. 1) solves (or actually avoids at the cost of security) the host key problem.