I am trying to connect to an SFTP site using python but the known_hosts file does not exist on my windows 10 machine. I found online that the host key appears when first connecting to the server: https://winscp.net/eng/docs/ssh_verifying_the_host_key
How do I convert this into a known_hosts file that I can use in my python code?
I tried creating a file like: hostname ssh-rsa 2EP...8MZ
in the example above but I receive an invalid host key error: Error('Incorrect padding'))
Thank you.
import pysftp
cnopts = pysftp.CnOpts(knownhosts='C:\\Users\\Documents\\known_hosts')
with pysftp.Connection('xxx',username='xxx', password='xxx',cnopts=cnopts) as sftp:
localpath='TEST.txt'
remotepath='TEST.txt'
sftp.put(localpath,remotepath)
sftp.close()