pysftp Host keys not found AWS PEM lightsail

If your using pysftp and your getting "host keys not found" error when trying to connect to instance, try the following:

(note: the following assumes you have openSSH installed. Windows users will need to manually install this)

1. Open a terminal and navigate to the folder containing the .pem file.

2. Run :
chmod 400 keyfile.pem
 
3. Use OpenSSH to ssh into your instance:
ssh -i "keyfile.pem" USERNAME@IP_OF_INSTANCE
And that's it! Your python script should work :)

Example python script:
import pysftp

sftp = pysftp.Connection(host="INSTANCE_IP", username="USERNAME", private_key=r"../file.pem")


SNAPPED!

SNAPPED!

Comments

Popular posts from this blog

Append to a json file python

Setup Mailhog mail server on Ubuntu