使用Paramiko时出现加密错误?

时间:2018-03-20 14:40:55

标签: python python-cryptography

我最近还没有更新任何我认为会影响nacl和paramiko签名过程的内容,但现在它不会起作用。我重新安装了paramiko和netmiko并确保所有加密库都是最新的。我不知道还有什么可做的,有什么想法吗?

from netmiko import ConnectHandler
...
def main(device_list):                                        
    username = input("\nWhat is your username? -> ")          
    password = getpass.getpass("\nWhat is your password? -> ")
    for host in device_list:                                  
        juniper_device = {                                    
        'device_type': 'juniper',                             
        'ip': host,                                           
        'username': username,                                 
        'password': password,                                 
        'verbose': False                                   
    }                                                     

Netmiko使用Paramiko库建立SSH连接。这段代码就是设置设备定义的原因。

以下是与设备创建和ssh连接打开相关联的堆栈跟踪。

Traceback (most recent call last):
  File "./get_running-config.py", line 5, in <module>
    from netmiko import ConnectHandler
  File "/usr/local/lib/python3.4/dist-packages/netmiko/__init__.py", line 8, in <module>
from netmiko.ssh_dispatcher import ConnectHandler
  File "/usr/local/lib/python3.4/dist-packages/netmiko/ssh_dispatcher.py", line 4, in <module>
from netmiko.a10 import A10SSH
  File "/usr/local/lib/python3.4/dist-packages/netmiko/a10/__init__.py", line 2, in <module>
from netmiko.a10.a10_ssh import A10SSH
  File "/usr/local/lib/python3.4/dist-packages/netmiko/a10/a10_ssh.py", line 4, in <module>
from netmiko.cisco_base_connection import CiscoSSHConnection
  File "/usr/local/lib/python3.4/dist-packages/netmiko/cisco_base_connection.py", line 3, in <module>
from netmiko.base_connection import BaseConnection
  File "/usr/local/lib/python3.4/dist-packages/netmiko/base_connection.py", line 13, in <module>
import paramiko
  File "/usr/local/lib/python3.4/dist-packages/paramiko/__init__.py", line 22, in <module>
from paramiko.transport import SecurityOptions, Transport
  File "/usr/local/lib/python3.4/dist-packages/paramiko/transport.py", line 57, in <module>
from paramiko.ed25519key import Ed25519Key
  File "/usr/local/lib/python3.4/dist-packages/paramiko/ed25519key.py", line 22, in <module>
import nacl.signing
  File "/usr/local/lib/python3.4/dist-packages/nacl/signing.py", line 19, in <module>
import nacl.bindings
  File "/usr/local/lib/python3.4/dist-packages/nacl/bindings/__init__.py", line 17, in <module>
from nacl.bindings.crypto_box import (
  File "/usr/local/lib/python3.4/dist-packages/nacl/bindings/crypto_box.py", line 27, in <module>
crypto_box_SEEDBYTES = lib.crypto_box_seedbytes()
AttributeError: cffi library '_sodium' has no function, constant or global variable named 'crypto_box_seedbytes'

2 个答案:

答案 0 :(得分:1)

经过对密码学和后续模块的大量修补,我刚刚安装了所有相关的库和现在的工作。不幸的是,不确定它是如何进入这个状态的,但重新开始更容易。

答案 1 :(得分:0)

除非您发布代码,否则需要进行一些猜测:

也许问题类似于https://github.com/mitmproxy/mitmproxy/issues/2372,它通过在版本1.9中安装cryptography包来解决。