Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Run ParallelSSHClient on 8 servers. One server is having port 422. All other servers on port 22 #361

Answered by pkittenis
sreenik250 asked this question in Q&A
Discussion options

I want to execute ParallelSSHClient on 8 servers. One server is having port 422. All other servers on port 22.
How to achieve this? If possible example please.

You must be logged in to vote

Hi there,

Have a look at per-host configuration documentation.

from pssh.config import HostConfig
hosts = ['localhost', 'localhost']
host_config = [
 HostConfig(port=422, user='user1',
 password='pass', private_key='my_pkey.pem'),
 HostConfig(user='user2',
 password='pass', private_key='my_other_key.pem'),
]
client = ParallelSSHClient(hosts, host_config=host_config)
client.run_command('uname')
<..>

Port can be omitted from HostConfig unless it's a non-default port. Default port is 22. If there is no need to override any configuration for a server an empty HostConfig may be used, eg:

host_config = [
 HostConfig(port=422),
 HostConfig(),
]

Overrid...

Replies: 2 comments

Comment options

We have stored the IP address in PostgreSQL database. How to store the HostConfig data in PostgreSQL.

You must be logged in to vote
0 replies
Comment options

Hi there,

Have a look at per-host configuration documentation.

from pssh.config import HostConfig
hosts = ['localhost', 'localhost']
host_config = [
 HostConfig(port=422, user='user1',
 password='pass', private_key='my_pkey.pem'),
 HostConfig(user='user2',
 password='pass', private_key='my_other_key.pem'),
]
client = ParallelSSHClient(hosts, host_config=host_config)
client.run_command('uname')
<..>

Port can be omitted from HostConfig unless it's a non-default port. Default port is 22. If there is no need to override any configuration for a server an empty HostConfig may be used, eg:

host_config = [
 HostConfig(port=422),
 HostConfig(),
]

Overrides port to 422 for only the first host. Second host gets ParallelSSHClient configuration.

Storing HostConfig data elsewhere is out of scope for the library. There are many ways to do that, up to developers.

The library uses HostConfig entries for per-host configuration. How/where/if they are stored is up to developers.

You must be logged in to vote
0 replies
Answer selected by pkittenis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /