我正在学习netconf,现在我只是想通过netconf连接到路由器。当我通过 cli "ssh -p 830 admin@10.22.108.13 -s netconf" 连接时,我可以毫无问题地连接到 iosxr 路由器,但是当我进行简单的 python 连接时,它似乎不起作用。我已经通过 pip3 安装了 ncclient。不知道我错过了什么。我已经在线查看了文档,一旦安装了 ncclient,它应该可以工作。我收到一个身份验证错误,不知道为什么,这是正确的用户/密码,当我通过 cli 连接到它时它可以工作。
from ncclient import manager
m = manager.connect(host='10.22.108.13',
port=830,
username='admin',
password='super',
device_params={'name':'iosxr'},
hostkey_verify=False)
print(m.connected)
for capabilities in m.server_capabilities:
print(capabilities)
m.close_session()
回溯(最后一次调用):文件“/Users/user1/Documents/scripts/Python/netconf_test.py”,第 3 行,在 m = manager.connect(host='10.22.108.13', File "/usr/local /lib/python3.9/site-packages/ncclient/manager.py”,第 176 行,在连接中返回 connect_ssh(*args, **kwds) 文件“/usr/local/lib/python3.9/site-packages/ ncclient/manager.py”,第 143 行,在 connect_ssh session.connect(*args, **kwds) 文件“/usr/local/lib/python3.9/site-packages/ncclient/transport/ssh.py”中,行361,在连接 self._auth(用户名,密码,key_filenames,allow_agent,look_for_keys)文件“/usr/local/lib/python3.9/site-packages/ncclient/transport/ssh.py”,第 466 行,在 _auth raise AuthenticationError(repr(saved_exception)) ncclient.transport.errors.AuthenticationError: AuthenticationException('身份验证超时。') [在 31.3 秒内完成,退出代码为 1] [shell_cmd: python3 -u "/Users/user1/Documents/scripts/Python/netconf_test.py"] [dir: /Users/user1/Documents/scripts/ Python] [路径:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Applications/Wireshark.app/Contents/MacOS ]