使用parallel-ssh模块,我尝试使用Natinve客户机运行SSH命令,但是得到了SessionHandshakeError
。如果我改用Paramiko客户端,一切都很好。我遇到了my_pkey.pub
的requirement与my_pkey
在同一个目录中。在
下面是我使用本机客户机的代码(将实际IP改为'ip1'
和'ip2'
):
from pssh.pssh2_client import ParallelSSHClient
pkey = os.path.dirname(os.path.abspath(__file__)) + '/my_pkey'
hosts = ['ip1', 'ip2']
client = ParallelSSHClient(hosts, user='root', pkey=pkey)
output = client.run_command('hostname')
for host, host_output in output.items():
for line in host_output.stdout:
print(line)
获取此错误:
^{pr2}$以下是我使用Paramiko客户端的代码(将实际IP更改为“ip1”和“ip2”):
from pssh.pssh_client import ParallelSSHClient
from pssh.utils import load_private_key
key_path = os.path.dirname(os.path.abspath(__file__)) + '/my_pkey'
pkey = load_private_key(key_path)
hosts = ['ip1', 'ip2']
client = ParallelSSHClient(hosts, user='root', pkey=pkey)
output = client.run_command('hostname')
for host, host_output in output.items():
for line in host_output.stdout:
print(line)
而且很管用。这是输出(我应该关心警告吗?)公司名称:
C:\Program Files (x86)\Python36-32\lib\site-packages\paramiko\ecdsakey.py:202: CryptographyDeprecationWarning: signer and verifier have been deprecated. Please use sign and verify instead.
signature, ec.ECDSA(self.ecdsa_curve.hash_object())
C:\Program Files (x86)\Python36-32\lib\site-packages\paramiko\rsakey.py:110: CryptographyDeprecationWarning: signer and verifier have been deprecated. Please use sign and verify instead.
algorithm=hashes.SHA1(),
ip1.hostname
ip2.hostname
Process finished with exit code 0
我对本地客户做了什么错事?在
这个错误被追踪到在Windows上用于
libssh2
的WinCNG后端-它不支持SHA-256主机密钥哈希,这在OpenSSH服务器的最新版本中是默认的。在parallel-ssh
,1.6.0
的latest version通过将Windows后端切换到OpenSSL以获得更好的兼容性并匹配OSX和Linux二进制控制盘,解决了这个问题。在有关详细信息,请参见release notes。在
一些解释,我从Panos在谷歌小组线程。这对我没有帮助,但也许对其他人有帮助。在
相关问题 更多 >
编程相关推荐