tldr/pages/common/pssh.md

28 lines
830 B
Markdown
Raw Normal View History

2017-07-11 19:02:25 +01:00
# pssh
2017-09-08 05:13:59 +01:00
> Parallel SSH program.
2017-07-11 19:02:25 +01:00
2017-09-08 05:13:59 +01:00
- Run a command on two hosts, and print its output on each server inline:
2017-07-11 19:02:25 +01:00
2017-09-08 05:13:59 +01:00
`pssh -i -H "{{host1}} {{host2}}" {{hostname -i}}`
2017-07-11 19:02:25 +01:00
- Run a command and save the output to separate files:
2017-09-08 05:13:59 +01:00
`pssh -H {{host1}} -H {{host2}} -o {{path/to/output_dir}} {{hostname -i}}`
2017-07-11 19:02:25 +01:00
2017-09-08 05:13:59 +01:00
- Run a command on multiple hosts, specified in a new-line separated file:
2017-07-11 19:02:25 +01:00
2017-09-08 05:13:59 +01:00
`pssh -i -h {{path/to/hosts_file}} {{hostname -i}}`
2017-07-11 19:02:25 +01:00
2017-09-08 05:13:59 +01:00
- Run a command as root (this asks for the root password):
2017-07-11 19:02:25 +01:00
2017-09-08 05:13:59 +01:00
`pssh -i -h {{path/to/hosts_file}} -A -l {{root_username}} {{hostname -i}}`
2017-07-11 19:02:25 +01:00
- Run a command with extra SSH arguments:
2017-09-08 05:13:59 +01:00
`pssh -i -h {{path/to/hosts_file}} -x "{{-O VisualHostKey=yes}}" {{hostname -i}}`
2017-07-11 19:02:25 +01:00
2017-09-08 05:13:59 +01:00
- Run a command limiting the number of parallel connections to 10:
2017-07-11 19:02:25 +01:00
`pssh -i -h {{path/to/hosts_file}} -p {{10}} '{{cd dir; ./script.sh; exit}}'`