I am trying to connect to a server using the following script:
import pysftp
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None
srv = pysftp.Connection(host="sftp://my_ip:my_port",
username="alessandro", password="alessandro", port=2222,
cnopts=cnopts)
data = srv.listdir()
srv.close()
for i in data:
print (i)
If I try to access via FileZilla or similar clients, with the same credentials, it works; even though it displays the following warning, concerning host key algorithm and fingerprint as:
however, the script does not run properly and reports the following error:
SSHException: Unable to connect to sftp://my_ip:my_port: [Errno 60] Operation timed out
Even if I try with host = my_ip only. Additionally, if I do not set cnopts, it does not find the host key.
How can I solve it?