11## Run Over SSH
22
3- This program runs a Bash command/ script over ssh in one or more hosts.
3+ Run a shell command or script over ssh in one or more hosts.
44
55### Installation
66
7- #### Ubuntu
7+ #### Debian/ Ubuntu
88```
99sudo apt install runoverssh
1010```
@@ -23,87 +23,62 @@ $ runoverssh [OPTIONS] USERNAME COMMAND HOSTS...
2323
2424### Default behavior
2525
26- * Ask each ` username@host ` password at the start
27- * SSH flags ` -o ConnectTimeout=5 -o StrictHostKeyChecking=no `
28- * Bash flags ` -l `
26+ * SSH flags: ` -o ConnectTimeout=5 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null `
2927* Prints all SSH output in the screen
3028
31- ### SSH Authentication
29+ ### Global Password
3230
33- ` sshpass ` is used for authenticating using a password.
34- For using SSH directly (no ` sshpass ` ), use the ` --nopw ` / ` -n ` flag.
35- This is useful for SSH public-key authentication .
31+ A global password can be used for all SSH connections.
32+ It requires ` sshpass ` to be installed.
33+ See the ` -g ` flag .
3634
3735### Options:
3836```
39- -g, --globalpw ask one global password for all connections
40- -s, --script [file] read commands from a script file instead
41- -r, --hostsfile [file] use the list of hosts from a file (one host per line)
42-
43- -n, --nopw no password (use ssh directly instead of sshpass)
44- -a, --args specify the arguments to be passed to the script file
45- -l, --log save ssh output (default: runoverssh.log) (append)
46- -q, --quiet disable ssh screen output
47-
48- --bashflags [flags] set custom bash flags
49- default: '-l'
50- --sshflags [flags] set custom ssh flags
51- default: '-o ConnectTimeout=5 -o StrictHostKeyChecking=no'
52- --logfile [file] save ssh output to a custom file (append)
53-
37+ -g, --globalpw Prompt a global password for all connections
38+ -s, --script FILE Read commands from a script file, disables
39+ the default COMMAND argument
40+ -r, --hostsfile FILE Read the list of hosts from a file (one host
41+ per line), disables the default HOSTS argument
42+ -a, --args Arguments (in a single string) to be passed to
43+ the script file.
44+ -q, --quiet Disable all screen output, except for password
45+ prompts. If logfile is set, output is written
46+ there
47+ -v, --verbose Print verbose messages
48+ --shell Remote shell to be used. Supported values:
49+ sh, bash
50+ default: bash
51+ --shellflags FLAGS Remote shell flags
52+ default: ''
53+ --sshflags FLAGS Local SSH flags
54+ default: -o ConnectTimeout=5
55+ -o StrictHostKeyChecking=no
56+ -o UserKnownHostsFile=/dev/null
57+ --logfile FILE Append SSH output to a file
5458```
5559
5660### Examples
61+ #### Restart Apache webserver in two hosts
5762```
58- # Restart Apache webserver in two hosts
59- $ runoverssh root "systemctl restart apache2" webserver webserver2
60- Please set root's password for each host:
61-
62- root@webserver password:
63- root@webserver2 password:
64-
65- Connecting as root@webserver...
66- Connecting as root@webserver2...
67- ```
63+ runoverssh root "systemctl restart apache2" webserver webserver2
6864```
69- # Reboot three hosts, which contain the same root password. Log the output.
70- $ runoverssh --log --globalpw root "reboot" host1 host2 host3
71- root's password (used for all connections):
7265
73- Connecting as root@host1...
74- Connecting as root@host2...
75- Connecting as root@host3...
66+ #### Reboot three hosts, which contain the same root password. Writes the SSH output to ` reboot.log ` .
7667```
68+ runoverssh --logfile reboot.log --globalpw root "reboot" host1 host2 host3
7769```
78- # Run puppet agent in all nodes listed in a file supressing output from ssh.
79- $ runoverssh -q -l -g -r puppet-nodes root "puppet agent -t"
80- root's password (used for all connections):
8170
82- Connecting as root@node1...
83- Connecting as root@node2...
84- Connecting as root@node3...
71+ #### Run puppet agent in all nodes listed in ` puppet-nodes ` , supressing the output
8572```
73+ runoverssh -q -g -r puppet-nodes root "puppet agent -t"
8674```
87- # Check git status on devmachine
88- $ runoverssh remoteuser "cd git-project && git status" devmachine
89- Please set remoteuser's password for each host:
90-
91- remoteuser@devmachine password:
9275
93- Connecting as remoteuser@devmachine...
94- On branch master
95- Your branch is up-to-date with 'origin/master'.
96- nothing to commit, working directory clean
76+ #### Check git status on devmachine
9777```
78+ runoverssh remoteuser "cd git-project && git status" devmachine
9879```
99- # Run backup script in all hosts listed in a file
100- $ runoverssh -g --script backup.sh --hostsfile hostlist remoteuser
101- remoteuser's password (used for all connections):
10280
103- Connecting as remoteuser@host1...
104- Backup successful
105- Connecting as remoteuser@host2...
106- Backup successful
107- Connecting as remoteuser@host3...
108- Backup successful
81+ #### Run backup script in all hosts listed in a file
82+ ```
83+ runoverssh -g --script backup.sh --hostsfile hostlist remoteuser
10984```
0 commit comments