Python pysftp: bypass ssh host key verification








import pysftp

cnopts = pysftp.CnOpts();

# set hostkeys to None to disable ssh key verification
cnopts.hostkeys = None
try:
   sftp = pysftp.Connection(host='sftp.yourdomain.org', username='sftp-user', password='password', port=22, cnopts=cnopts)
   print(sftp.pwd)
finally:
   if sftp:
       sftp.close()



No comments:

Post a Comment