簡體   English   中英

paramiko.ssh_exception.SSHException: 找不到主機 xx.xx.xx.xxx 的主機密鑰

[英]paramiko.ssh_exception.SSHException: No hostkey for host xx.xx.xx.xxx found

我正在嘗試使用 pysftp 並得到與許多其他人相同的錯誤。 主機沒有主機密鑰。 我嘗試了很多修復,但似乎沒有一個有效。

當我嘗試設置主機名時,出現以下錯誤:

cnopts = pysftp.CnOpts()
cnopts.hostkeys.load('known_hosts')

with pysftp.Connection(host, username, password, cnopts=cnopts) as sftp:
/home/runner/.local/share/virtualenvs/python3/lib/python3.7/site-packages/pysftp/__init__.py:61: UserWarning: Failed to load HostKeys from /home/runner/.ssh/known_hosts.  You will need to explicitly load HostKeys (cnopts.hostkeys.load(filename)) or disableHostKey checking (cnopts.hostkeys = None).
  warnings.warn(wmsg, UserWarning)

我還嘗試關閉主機密鑰並在本地加載,但似乎沒有任何效果。

如果默認位置中不存在known_hosts並且您未在CnOpts構造函數中指定替代位置, CnOpts收到該警告。

這應該有效:

cnopts = pysftp.CnOpts(knownhosts='known_hosts')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM