Reputation: 31
I am running Python 3.6.8 on RHEL 8
I am trying to connect to sftp on another server using this #!/usr/bin/env python
import pysftp
myHostname = I.I.I.I
myport = PPPP
myUsername = xxx
myPassword = xxx
cnopts = pysftp.CnOpts(knownhosts='/home/xxx/.ssh/known_hosts')
with pysftp.Connection(host=myHostname, port=myport, username=myUsername, password=myPassword, cnopts=cnopts) as sftp:
I get this error:
Exception has occurred: SSHException
No hostkey for host I.I.I.I found.
File "/home/xxxx/python/xxxxy", line 16, in <module>
with pysftp.Connection(host=myHostname, port=myport, username=myUsername,
password=myPassword, cnopts=cnopts) as sftp:
But when I query cnopts.hostkeys I find the server listed
[I.I.I.I]:PPPP
the IP Address found in cnopts is the same IP Address in the SFTP command
if I insert this line into my script:
cnopts.hostkeys = None
I connect fine to the far end
This points that connectivity and authentication is working fine.
Any suggestions?
Upvotes: 2
Views: 290