Python PSFTP 找不到主机 xxxx 的主机密钥
我正在 RHEL 8 上运行 Python 3.6.8
我正在尝试使用此连接到另一台服务器上的 sftp #!/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:
我收到此错误:
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:
但是,当我查询 cnopts.hostkeys 时,我发现列出的服务器
[I.I.I.I]:PPPP
在 cnopts 中找到的 IP 地址与 SFTP 命令中的 IP 地址相同
,如果我将此行插入脚本中:
cnopts.hostkeys = None
我可以很好地连接到远端
这表明连接和身份验证工作正常。
有什么建议吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论