Python Pysftp Error

后端 未结 2 1705
既然无缘
既然无缘 2020-12-31 23:45

My code:

import pysftp 
s = pysftp.Connection(host=\'test.rebex.net\', username=\'demo\', password=\'password\') 
data = s.listdir() 
s.close() 
for i in dat         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-01 00:41

    updating the package didn't work for me, as it was already up-to-date (latest for python 2.7 at least)

    Found a better aproach here.

    1) You can manualy add the ssh key to the known_hosts file

    ssh test.rebex.net
    

    2) Or you can set a flag to ignore it

    import pysftp
    cnopts = pysftp.CnOpts()
    cnopts.hostkeys = None    # disable host key checking.
    with pysftp.Connection('host', username='me',private_key=private_key,
                               private_key_pass=private_key_password,
                               cnopts=cnopts) as sftp
        # do stuff here
    

提交回复
热议问题