Python Parallel SSH-如何传递多个用户名和密码

问题描述

我正在尝试使用ParallelSSHClient进行并行SSH。

当我以 主机= ['x.x.x.x','y.y.y.y'] ParallelSSHClient(主机,“用户”,“通过”) 一切正常。但是,如果x.x.x.x和y.y.y.y的用户名和密码不同怎么办? 我还必须通过用户名和密码作为列表权限。但是,如果我通过了,那就行不通了。

解决方法

每个并行SSH的文档:

from pssh.config import HostConfig

hosts = ['localhost','localhost']
host_config = [
    HostConfig(port=2222,user='user1',password='pass',private_key='my_pkey.pem'),HostConfig(port=2223,user='user2',private_key='my_other_key.pem'),]

client = ParallelSSHClient(hosts,host_config=host_config)
client.run_command('uname')

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...