Python Parallel SSH - How to pass multiple username and password

1.1k views Asked by At

I am trying to do parallel SSH using ParallelSSHClient.

When I run as hosts = ['x.x.x.x', 'y.y.y.y'] ParallelSSHClient (hosts, 'user', 'pass') It is working fine. But what if the username and password varies for x.x.x.x and y.y.y.y? I have to pass username and password also as list right. But if I pass , it is not working.

1

There are 1 answers

0
Jeroen On

Per documentation of parallel 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',
               password='pass', private_key='my_other_key.pem'),
]

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