gpt4 book ai didi

ssh - ncclient : connecting to a NETCONF server

转载 作者:行者123 更新时间:2023-12-02 14:17:39 31 4
gpt4 key购买 nike

我想使用 python 库 ncclient 0.6.6 和 Python 2.7.15 连接到 NETCONF 服务器 (netopeer2) 并读出正在运行的配置。

我尝试按照手册中的示例,在控制台中运行此代码:

with manager.connect(host="*the IP adress*", port=*the port*, timeout=None, username="*user*", password="*pwd*") as m:
c = m.get_config(source='running').data_xml
with open("%s.xml" % host, 'w') as f:
f.write(c)

如手册中所述,我尝试使用 allow_agent 和 look_for_keys 为 False 禁用公钥身份验证。不幸的是,这不能正常工作,因为我收到错误消息:
  File "<stdin>", line 1, in <module>
File "/home/sisc/.local/lib/python2.7/site-packages/ncclient/manager.py", line 177, in connect
return connect_ssh(*args, **kwds)
File "/home/sisc/.local/lib/python2.7/site-packages/ncclient/manager.py", line 143, in connect_ssh
session.connect(*args, **kwds)
File "/home/sisc/.local/lib/python2.7/site-packages/ncclient/transport/ssh.py", line 481, in connect
raise SSHUnknownHostError(known_hosts_lookup, fingerprint)
ncclient.transport.errors.SSHUnknownHostError: Unknown host key [e3:8d:35:a9:43:f9:3c:8a:f4:d3:88:5b:a9:36:93:59] for [[192.168.56.2]:1831]

我不明白为什么它仍然提示未知的主机 key ,即使我明确禁用了公钥身份验证。
netopeer NETCONF 服务器肯定正在运行,因为一旦我尝试从终端通过 SSH 连接到它,我就会收到一条“Hello”消息。
我错过了什么?

最佳答案

m = manager.connect(host="172.17.0.2", port=830, username="netconf", password="netconf", hostkey_verify=False)

成功了。 Hostkey_verify 必须为假。

关于ssh - ncclient : connecting to a NETCONF server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56634650/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com