PSSH私钥问题

时间:2017-03-06 07:20:10

标签: python paramiko pssh

我是PSSH的新手。我按照PSSH文档编写了脚本。当我使用私钥时,它返回错误“ImportError:没有名为ecdsakey的模块” 我尝试下载该模块,但没有“ecdsakey”模块,可用的模块是“ecdsa”,它已经安装。搜索到处都找不到相关的答案。我正在使用ubuntu14.04操作系统

from __future__ import print_function
from pprint import pprint
import paramiko
from pssh.pssh_client import ParallelSSHClient
from pssh.exceptions import AuthenticationException,UnknownHostException,ConnectionErrorException
client_key = paramiko.RSAKey.from_private_key_file('/home/ubuntu/Downloads/pssh.txt')
client=ParallelSSHClient(['ip1','ip2'],pkey=client_key)
try:
    output=client.run_command('ls /',sudo=True)
except(AuthenticationException,UnknownHostException,ConnectionErrorException):
    pass 

错误:

Traceback (most recent call last):
File "pssh1.py", line 4, in <module>
from pssh.utils import load_private_key
File "/usr/local/lib/python2.7/dist-packages/pssh/__init__.py", line 33, in <module>
from .pssh_client import ParallelSSHClient
File "/usr/local/lib/python2.7/dist-packages/pssh/pssh_client.py", line 36, in <module>
from .ssh_client import SSHClient
File "/usr/local/lib/python2.7/dist-packages/gevent/builtins.py", line 93, in __import__
result = _import(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pssh/ssh_client.py", line 32, in <module>
from .utils import read_openssh_config
File "/usr/local/lib/python2.7/dist-packages/gevent/builtins.py", line 93, in __import__
result = _import(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pssh/utils.py", line 27, in <module>
from paramiko.ecdsakey import ECDSAKey
File "/usr/local/lib/python2.7/dist-packages/gevent/builtins.py", line 93, in __import__
result = _import(*args, **kwargs)
ImportError: No module named ecdsakey

1 个答案:

答案 0 :(得分:0)

尝试以下命令:

sudo pip install ecdsa

如果您使用的是Python 3.x,则可能必须使用pip3而不是pip:

sudo pip3 install ecdsa