netmiko连接错误-TypeError:connect()得到了意外的关键字参数“ passphrase”

时间:2018-09-03 08:54:28

标签: python cisco

我正在与netmiko迈出第​​一步,并尝试建立基本连接:

from netmiko import ConnectHandler

device = ConnectHandler(device_type="cisco_ios", ip="10.118.10.8", username="name", password="passowrd")
output = device.send_command("show version")
print output
device.disconnect()

我都尝试使用device_type =“ cisco_ios”和arista_eos,两次都收到以下消息:

Traceback (most recent call last):
File "netmiko_v1.py", line 3, in <module>
device = ConnectHandler(device_type="cisco_ios", ip="10.118.10.8", username="name", password="password")
File "build/bdist.linux-x86_64/egg/netmiko/ssh_dispatcher.py", line 205, in ConnectHandler
File "build/bdist.linux-x86_64/egg/netmiko/base_connection.py", line 270, in __init__
File "build/bdist.linux-x86_64/egg/netmiko/base_connection.py", line 766, in establish_connection
TypeError: connect() got an unexpected keyword argument 'passphrase'

我假设我遇到了非常简单明显的错误,有什么建议吗?

添加数据包捕获对目标IP地址没有任何作用,因此假设这是本地问题。由于主机上权限不足,我不得不在用户空间中安装netmiko,不确定是否会引起问题?

2 个答案:

答案 0 :(得分:1)

这不是netmiko问题。它使用的paramiko库似乎有问题。确保将设置上的paramiko版本升级到最新版本(在我的情况下为2.4.1):-

    >>> import paramiko
    >>> print paramiko.__version__
    2.4.1

    I saw this issue if the version of paramiko is 2.0.0 or less
    ##### Log Below ########
    >>> import paramiko
    >>> print paramiko.__version__
    2.0.0

    >>> from netmiko import ConnectHandler
    >>> dut1 = {
    ...     'device_type': 'vyos',
    ...     'ip': 'X.X.X.X',
    ...     'username': 'XXXX',
    ...     'password': 'XXX',
    ... }
    >>> t = ConnectHandler(**dut1)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "netmiko/ssh_dispatcher.py", line 210, in ConnectHandler
        return ConnectionClass(*args, **kwargs)
      File "netmiko/base_connection.py", line 270, in __init__
        self.establish_connection()
      File "netmiko/base_connection.py", line 766, in establish_connection
        self.remote_conn_pre.connect(**ssh_connect_params)
TypeError: connect() got an unexpected keyword argument 'passphrase'

 Hope this helps.

答案 1 :(得分:0)

这是一个Netmiko问题,因为这意味着我需要滚动Netmiko版本要求以指定更新版本的Paramiko,但是的,这可能会解决它。