Python PSFTP 找不到主机 xxxx 的主机密钥

发布于 2025-01-10 10:31:53 字数 934 浏览 1 评论 0原文

我正在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文