PSSH 私钥问题
Posted
技术标签:
【中文标题】PSSH 私钥问题【英文标题】:PSSH private key issue 【发布时间】:2017-07-25 23:21:48 【问题描述】:我是 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】:试试这些命令:
sudo pip install ecdsa
如果您使用的是 Python 3.x,则可能必须使用 pip3 而不是 pip:
sudo pip3 install ecdsa
【讨论】:
以上是关于PSSH 私钥问题的主要内容,如果未能解决你的问题,请参考以下文章