multiSSH3 5.41__py3-none-any.whl → 5.43__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of multiSSH3 might be problematic. Click here for more details.

@@ -1,376 +1,377 @@
1
- Metadata-Version: 2.2
2
- Name: multiSSH3
3
- Version: 5.41
4
- Summary: Run commands on multiple hosts via SSH
5
- Home-page: https://github.com/yufei-pan/multiSSH3
6
- Author: Yufei Pan
7
- Author-email: pan@zopyr.us
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
10
- Classifier: Operating System :: POSIX :: Linux
11
- Requires-Python: >=3.6
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
- Requires-Dist: argparse
15
- Requires-Dist: ipaddress
16
- Dynamic: author
17
- Dynamic: author-email
18
- Dynamic: classifier
19
- Dynamic: description
20
- Dynamic: description-content-type
21
- Dynamic: home-page
22
- Dynamic: requires-dist
23
- Dynamic: requires-python
24
- Dynamic: summary
25
-
26
- # multiSSH3
27
- A script that is able to issue commands to multiple hosts while monitoring their progress.
28
- Can be used in bash scripts for automation actions.
29
- Also able to be imported and / or use with Flexec SSH Backend to perform cluster automation actions.
30
-
31
- Install via
32
- ```bash
33
- pip install multiSSH3
34
- ```
35
-
36
- multiSSH3 will be available as
37
- ```bash
38
- mssh
39
- mssh3
40
- multissh
41
- multissh3
42
- multiSSH3
43
- ```
44
-
45
- multissh will read a config file located at ```/etc/multiSSH3.config.json```
46
-
47
- To store / generate a config file with the current command line options, you can use
48
-
49
- ```bash
50
- mssh --store_config_file
51
- ```
52
-
53
- You can modify the json file directly after generation and multissh will read from it for loading defaults.
54
-
55
- ```bash
56
- mssh --ipmi_interface_ip_prefix 192 --store_config_file
57
- ```
58
- will store
59
- ```json
60
- "DEFAULT_IPMI_INTERFACE_IP_PREFIX": "192"
61
- ```
62
- into the json file.
63
-
64
- Note:
65
-
66
- If you want to store password, it will be a plain text password in this config file. This will be better to supply it everytime as a CLI argument but you should really consider setting up priv-pub key setup.
67
-
68
- Also Note:
69
-
70
- On some systems, scp / rsync will require you use a priv-pub key to work
71
-
72
- This option can also be used to store cli options into the config files. For example.
73
-
74
- By defualt reads bash env variables for hostname aliases. Also able to read
75
- ```bash
76
- DEFAULT_ENV_FILE = '/etc/profile.d/hosts.sh'
77
- ```
78
- as hostname aliases.
79
-
80
- multissh3 will resolve hostname grouping by:
81
- ipv4 address expansion > local hostname resolution ( like /etc/hosts ) > currrent terminal environment > env from env_file > remote hostname resolution ( socket.gethostbyname() )
82
-
83
- An example hostname alias file will look like:
84
- ```bash
85
- us_east='100.100.0.1-3,us_east_prod_[1-5]'
86
- us_central=""
87
- us_west="100.101.0.1-2,us_west_prod_[a-c]_[1-3]"
88
- us="$us_east,$us_central,$us_west"
89
- asia="100.90.0-1.1-9"
90
- eu=''
91
- rhel8="$asia,$us_east"
92
- all="$us,$asia,$eu"
93
- ```
94
- ( You can use bash replacements for grouping. )
95
-
96
- For example:
97
- ```bash
98
- export all='192.168.1-2.1-64'
99
- mssh all 'echo hi'
100
- ```
101
-
102
- Note: you probably want to set presistent ssh connections to speed up each connection events.
103
- An example .ssh/config:
104
- ```bash
105
- Host *
106
- StrictHostKeyChecking no
107
- ControlMaster auto
108
- ControlPath /tmp/%u_ssh_sockets_%r@%h-%p
109
- ControlPersist 3600
110
- ```
111
-
112
- It is also able to recognize ip blocks / number blocks / hex blocks / character blocks directly.
113
-
114
- For example:
115
- ```bash
116
- mssh testrig[1-10] lsblk
117
- mssh ww[a-c],10.100.0.* 'cat /etc/fstab' 'sed -i "/lustre/d' /etc/fstab' 'cat /etc/fstab'
118
- ```
119
-
120
- It also supports interactive inputs. ( and able to async boardcast to all supplied hosts )
121
- ```bash
122
- mssh www bash
123
- ```
124
-
125
- By default, it will try to fit everything inside your window.
126
- ```bash
127
- DEFAULT_CURSES_MINIMUM_CHAR_LEN = 40
128
- DEFAULT_CURSES_MINIMUM_LINE_LEN = 1
129
- ```
130
- While leaving minimum 40 characters / 1 line for each host display by default. You can modify this by using -ww and -wh.
131
-
132
-
133
- Use ```mssh --help``` for more info.
134
-
135
- ```bash
136
- usage: mssh [-h] [-u USERNAME] [-p PASSWORD] [-k [KEY]] [-uk] [-ea EXTRAARGS] [-11] [-f FILE] [-fs] [--scp] [-gm] [-t TIMEOUT] [-r REPEAT]
137
- [-i INTERVAL] [--ipmi] [-mpre IPMI_INTERFACE_IP_PREFIX] [-pre INTERFACE_IP_PREFIX] [-q] [-ww WINDOW_WIDTH] [-wh WINDOW_HEIGHT]
138
- [-sw] [-eo] [-no] [--no_env] [--env_file ENV_FILE] [-m MAX_CONNECTIONS] [-j] [--success_hosts] [-g] [-su | -nsu]
139
- [-sh SKIP_HOSTS] [--store_config_file] [--debug] [-ci] [-V]
140
- [hosts] [commands ...]
141
-
142
- Run a command on multiple hosts, Use #HOST# or #HOSTNAME# to replace the host name in the command. Config file: /etc/multiSSH3.config.json
143
-
144
- positional arguments:
145
- hosts Hosts to run the command on, use "," to seperate hosts. (default: all)
146
- commands the command to run on the hosts / the destination of the files #HOST# or #HOSTNAME# will be replaced with the host
147
- name.
148
-
149
- options:
150
- -h, --help show this help message and exit
151
- -u USERNAME, --username USERNAME
152
- The general username to use to connect to the hosts. Will get overwrote by individual username@host if specified.
153
- (default: None)
154
- -p PASSWORD, --password PASSWORD
155
- The password to use to connect to the hosts, (default: )
156
- -k [KEY], --key [KEY], --identity [KEY]
157
- The identity file to use to connect to the hosts. Implies --use_key. Specify a folder for program to search for a
158
- key. Use option without value to use ~/.ssh/ (default: None)
159
- -uk, --use_key Attempt to use public key file to connect to the hosts. (default: False)
160
- -ea EXTRAARGS, --extraargs EXTRAARGS
161
- Extra arguments to pass to the ssh / rsync / scp command. Put in one string for multiple arguments.Use "=" ! Ex.
162
- -ea="--delete" (default: None)
163
- -11, --oneonone Run one corresponding command on each host. (default: False)
164
- -f FILE, --file FILE The file to be copied to the hosts. Use -f multiple times to copy multiple files
165
- -fs, --file_sync Operate in file sync mode, sync path in <COMMANDS> from this machine to <HOSTS>. Treat --file <FILE> and
166
- <COMMANDS> both as source as source and destination will be the same in this mode. (default: False)
167
- --scp Use scp for copying files instead of rsync. Need to use this on windows. (default: False)
168
- -gm, --gather_mode Gather files from the hosts instead of sending files to the hosts. Will send remote files specified in <FILE> to
169
- local path specified in <COMMANDS> (default: False)
170
- -t TIMEOUT, --timeout TIMEOUT
171
- Timeout for each command in seconds (default: 600 (disabled))
172
- -r REPEAT, --repeat REPEAT
173
- Repeat the command for a number of times (default: 1)
174
- -i INTERVAL, --interval INTERVAL
175
- Interval between repeats in seconds (default: 0)
176
- --ipmi Use ipmitool to run the command. (default: False)
177
- -mpre IPMI_INTERFACE_IP_PREFIX, --ipmi_interface_ip_prefix IPMI_INTERFACE_IP_PREFIX
178
- The prefix of the IPMI interfaces (default: )
179
- -pre INTERFACE_IP_PREFIX, --interface_ip_prefix INTERFACE_IP_PREFIX
180
- The prefix of the for the interfaces (default: None)
181
- -q, -nw, --nowatch, --quiet
182
- Quiet mode, no curses watch, only print the output. (default: False)
183
- -ww WINDOW_WIDTH, --window_width WINDOW_WIDTH
184
- The minimum character length of the curses window. (default: 40)
185
- -wh WINDOW_HEIGHT, --window_height WINDOW_HEIGHT
186
- The minimum line height of the curses window. (default: 5)
187
- -sw, --single_window Use a single window for all hosts. (default: False)
188
- -eo, --error_only Only print the error output. (default: False)
189
- -no, --no_output Do not print the output. (default: False)
190
- --no_env Do not load the command line environment variables. (default: False)
191
- --env_file ENV_FILE The file to load the mssh file based environment variables from. ( Still work with --no_env ) (default:
192
- /etc/profile.d/hosts.sh)
193
- -m MAX_CONNECTIONS, --max_connections MAX_CONNECTIONS
194
- Max number of connections to use (default: 4 * cpu_count)
195
- -j, --json Output in json format. (default: False)
196
- --success_hosts Output the hosts that succeeded in summary as wells. (default: False)
197
- -g, --greppable, --table
198
- Output in greppable format. (default: False)
199
- -su, --skip_unreachable
200
- Skip unreachable hosts. Note: Timedout Hosts are considered unreachable. Note: multiple command sequence will
201
- still auto skip unreachable hosts. (default: False)
202
- -nsu, --no_skip_unreachable
203
- Do not skip unreachable hosts. Note: Timedout Hosts are considered unreachable. Note: multiple command sequence
204
- will still auto skip unreachable hosts. (default: True)
205
- -sh SKIP_HOSTS, --skip_hosts SKIP_HOSTS
206
- Skip the hosts in the list. (default: None)
207
- --store_config_file Store / generate the default config file from command line argument and current config at
208
- /etc/multiSSH3.config.json
209
- --debug Print debug information
210
- -ci, --copy_id Copy the ssh id to the hosts
211
- -V, --version show program's version number and exit
212
- ```
213
-
214
- Following document is generated courtesy of Mr.ChatGPT-o1 Preview:
215
-
216
- # multissh
217
-
218
- `multissh` is a powerful Python script that allows you to run commands on multiple hosts concurrently over SSH. It supports various features such as copying files, handling IP address ranges, using IPMI, and more. It's designed to simplify the management of multiple remote systems by automating command execution and file synchronization.
219
-
220
- ## Table of Contents
221
-
222
- - [multiSSH3](#multissh3)
223
- - [multissh](#multissh)
224
- - [Table of Contents](#table-of-contents)
225
- - [Features](#features)
226
- - [Basic Syntax](#basic-syntax)
227
- - [Command-Line Options](#command-line-options)
228
- - [Examples](#examples)
229
- - [Running a Command on Multiple Hosts](#running-a-command-on-multiple-hosts)
230
- - [Copying Files to Multiple Hosts](#copying-files-to-multiple-hosts)
231
- - [Using Hostname Ranges](#using-hostname-ranges)
232
- - [Using IPMI](#using-ipmi)
233
- - [Using Password Authentication](#using-password-authentication)
234
- - [Skipping Unreachable Hosts](#skipping-unreachable-hosts)
235
- - [JSON Output](#json-output)
236
- - [Quiet Mode](#quiet-mode)
237
- - [Environment Variables](#environment-variables)
238
- - [Notes](#notes)
239
- - [License](#license)
240
-
241
- ## Features
242
-
243
- - **Concurrent Execution**: Run commands on multiple hosts concurrently with controlled parallelism.
244
- - **File Transfer**: Copy files or synchronize directories to multiple hosts using `rsync` or `scp`.
245
- - **Hostname Expansion**: Support for hostname ranges and wildcards for easy targeting of multiple hosts.
246
- - **IPMI Support**: Execute IPMI commands on remote hosts.
247
- - **Authentication**: Support for SSH password authentication and key-based authentication.
248
- - **Custom SSH Options**: Pass extra arguments to SSH, `rsync`, or `scp` commands.
249
- - **Skip Unreachable Hosts**: Option to skip hosts that are unreachable.
250
- - **Output Formats**: Supports JSON and greppable output formats.
251
- - **Interactive Mode**: Run interactive commands with curses-based UI for monitoring.
252
- - **Quiet Mode**: Suppress output for cleaner automation scripts.
253
-
254
- ### Basic Syntax
255
-
256
- ```bash
257
- mssh [options] <hosts> <commands>
258
- ```
259
-
260
- - `<hosts>`: Comma-separated list of target hosts. Supports ranges and wildcards.
261
- - `<commands>`: Command(s) to execute on the target hosts.
262
-
263
- ### Command-Line Options
264
-
265
- | Short Option | Long Option | Description |
266
- |--------------|---------------------------|-----------------------------------------------------------------------------------------------------------|
267
- | `-u` | `--username` | Username for SSH connections. |
268
- | `-ea` | `--extraargs` | Extra arguments for SSH/rsync/scp commands. |
269
- | `-p` | `--password` | Password for SSH authentication. Requires `sshpass`. |
270
- | `-11` | `--oneonone` | Run one command per host (commands and hosts lists must have the same length). |
271
- | `-f` | `--file` | File(s) to copy to the hosts. Can be used multiple times. |
272
- | | `--file_sync` | Synchronize directories instead of copying files. |
273
- | | `--scp` | Use `scp` instead of `rsync` for file transfer. |
274
- | `-t` | `--timeout` | Command execution timeout in seconds. |
275
- | `-r` | `--repeat` | Number of times to repeat the command execution. |
276
- | `-i` | `--interval` | Interval between command repetitions in seconds. |
277
- | | `--ipmi` | Use IPMI to execute commands. |
278
- | `-pre` | `--interface_ip_prefix` | IP prefix for interface selection. |
279
- | `-q` | `--quiet` | Suppress output. |
280
- | `-ww` | `--window_width` | Minimum character width for the curses window. |
281
- | `-wh` | `--window_height` | Minimum line height for the curses window. |
282
- | `-sw` | `--single_window` | Use a single window for all hosts in curses mode. |
283
- | `-eo` | `--error_only` | Only display error outputs. |
284
- | `-no` | `--nooutput` | Do not print any output. |
285
- | | `--no_env` | Do not load environment variables from files. |
286
- | | `--env_file` | Specify a custom environment file. |
287
- | `-m` | `--maxconnections` | Maximum number of concurrent SSH connections. |
288
- | `-j` | `--json` | Output results in JSON format. |
289
- | | `--success_hosts` | Also display hosts where commands succeeded. |
290
- | `-g` | `--greppable` | Output results in a greppable format. |
291
- | `-nw` | `--nowatch` | Do not use curses mode; use simple output instead. |
292
- | `-su` | `--skipunreachable` | Skip hosts that are unreachable. |
293
- | `-sh` | `--skiphosts` | Comma-separated list of hosts to skip. |
294
- | `-V` | `--version` | Display the script version and exit. |
295
-
296
- ## Examples
297
-
298
- ### Running a Command on Multiple Hosts
299
-
300
- ```bash
301
- mssh "host1,host2,host3" "uptime"
302
- ```
303
-
304
- This command runs `uptime` on `host1`, `host2`, and `host3`.
305
-
306
- ### Copying Files to Multiple Hosts
307
-
308
- ```bash
309
- mssh -f "/path/to/local/file.txt" "host1,host2,host3" "/remote/path/"
310
- ```
311
-
312
- This command copies `file.txt` to `/remote/path/` on the specified hosts.
313
-
314
- ### Using Hostname Ranges
315
-
316
- ```bash
317
- mssh "host[01-05]" "hostname"
318
- ```
319
-
320
- This expands to `host01`, `host02`, `host03`, `host04`, `host05` and runs `hostname` on each.
321
-
322
- ### Using IPMI
323
-
324
- ```bash
325
- mssh --ipmi "192.168.1.[100-105]" "chassis power status"
326
- ```
327
-
328
- Runs `ipmitool chassis power status` on the specified IPMI interfaces.
329
-
330
- ### Using Password Authentication
331
-
332
- ```bash
333
- mssh -p "yourpassword" "host1,host2" "whoami"
334
- ```
335
-
336
- Uses `sshpass` to provide the password for SSH authentication.
337
-
338
- ### Skipping Unreachable Hosts
339
-
340
- ```bash
341
- mssh -su "host1,host2,host3" "date"
342
- ```
343
-
344
- Skips hosts that are unreachable during execution.
345
-
346
- ### JSON Output
347
-
348
- ```bash
349
- mssh -j "host1,host2" "uname -a"
350
- ```
351
-
352
- Outputs the results in JSON format, suitable for parsing.
353
-
354
- ### Quiet Mode
355
-
356
- ```bash
357
- mssh -q "host1,host2" "ls /nonexistent"
358
- ```
359
-
360
- Suppresses all output, useful for scripts where you only care about exit codes.
361
-
362
- ## Environment Variables
363
-
364
- - The script can load environment variables from a file (default: `/etc/profile.d/hosts.sh`) to resolve hostnames.
365
- - Use the `--env_file` option to specify a custom environment file.
366
- - Use `--no_env` to prevent loading any environment variables from files.
367
-
368
- ## Notes
369
- - **Dependencies**: Requires Python 3, `sshpass` (if using password authentication), and standard Unix utilities like `ssh`, `scp`, and `rsync`.
370
- - **Signal Handling**: Supports graceful termination with `Ctrl+C`.
371
-
372
- ## License
373
-
374
- This script is provided "as is" without any warranty. Use it at your own risk.
375
-
376
- ---
1
+ Metadata-Version: 2.2
2
+ Name: multiSSH3
3
+ Version: 5.43
4
+ Summary: Run commands on multiple hosts via SSH
5
+ Home-page: https://github.com/yufei-pan/multiSSH3
6
+ Author: Yufei Pan
7
+ Author-email: pan@zopyr.us
8
+ License: GPLv3+
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
11
+ Classifier: Operating System :: POSIX :: Linux
12
+ Requires-Python: >=3.6
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: argparse
15
+ Requires-Dist: ipaddress
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: classifier
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: home-page
22
+ Dynamic: license
23
+ Dynamic: requires-dist
24
+ Dynamic: requires-python
25
+ Dynamic: summary
26
+
27
+ # multiSSH3
28
+ A script that is able to issue commands to multiple hosts while monitoring their progress.
29
+ Can be used in bash scripts for automation actions.
30
+ Also able to be imported and / or use with Flexec SSH Backend to perform cluster automation actions.
31
+
32
+ Install via
33
+ ```bash
34
+ pip install multiSSH3
35
+ ```
36
+
37
+ multiSSH3 will be available as
38
+ ```bash
39
+ mssh
40
+ mssh3
41
+ multissh
42
+ multissh3
43
+ multiSSH3
44
+ ```
45
+
46
+ multissh will read a config file located at ```/etc/multiSSH3.config.json```
47
+
48
+ To store / generate a config file with the current command line options, you can use
49
+
50
+ ```bash
51
+ mssh --store_config_file
52
+ ```
53
+
54
+ You can modify the json file directly after generation and multissh will read from it for loading defaults.
55
+
56
+ ```bash
57
+ mssh --ipmi_interface_ip_prefix 192 --store_config_file
58
+ ```
59
+ will store
60
+ ```json
61
+ "DEFAULT_IPMI_INTERFACE_IP_PREFIX": "192"
62
+ ```
63
+ into the json file.
64
+
65
+ Note:
66
+
67
+ If you want to store password, it will be a plain text password in this config file. This will be better to supply it everytime as a CLI argument but you should really consider setting up priv-pub key setup.
68
+
69
+ Also Note:
70
+
71
+ On some systems, scp / rsync will require you use a priv-pub key to work
72
+
73
+ This option can also be used to store cli options into the config files. For example.
74
+
75
+ By defualt reads bash env variables for hostname aliases. Also able to read
76
+ ```bash
77
+ DEFAULT_ENV_FILE = '/etc/profile.d/hosts.sh'
78
+ ```
79
+ as hostname aliases.
80
+
81
+ multissh3 will resolve hostname grouping by:
82
+ ipv4 address expansion > local hostname resolution ( like /etc/hosts ) > currrent terminal environment > env from env_file > remote hostname resolution ( socket.gethostbyname() )
83
+
84
+ An example hostname alias file will look like:
85
+ ```bash
86
+ us_east='100.100.0.1-3,us_east_prod_[1-5]'
87
+ us_central=""
88
+ us_west="100.101.0.1-2,us_west_prod_[a-c]_[1-3]"
89
+ us="$us_east,$us_central,$us_west"
90
+ asia="100.90.0-1.1-9"
91
+ eu=''
92
+ rhel8="$asia,$us_east"
93
+ all="$us,$asia,$eu"
94
+ ```
95
+ ( You can use bash replacements for grouping. )
96
+
97
+ For example:
98
+ ```bash
99
+ export all='192.168.1-2.1-64'
100
+ mssh all 'echo hi'
101
+ ```
102
+
103
+ Note: you probably want to set presistent ssh connections to speed up each connection events.
104
+ An example .ssh/config:
105
+ ```bash
106
+ Host *
107
+ StrictHostKeyChecking no
108
+ ControlMaster auto
109
+ ControlPath /tmp/%u_ssh_sockets_%r@%h-%p
110
+ ControlPersist 3600
111
+ ```
112
+
113
+ It is also able to recognize ip blocks / number blocks / hex blocks / character blocks directly.
114
+
115
+ For example:
116
+ ```bash
117
+ mssh testrig[1-10] lsblk
118
+ mssh ww[a-c],10.100.0.* 'cat /etc/fstab' 'sed -i "/lustre/d' /etc/fstab' 'cat /etc/fstab'
119
+ ```
120
+
121
+ It also supports interactive inputs. ( and able to async boardcast to all supplied hosts )
122
+ ```bash
123
+ mssh www bash
124
+ ```
125
+
126
+ By default, it will try to fit everything inside your window.
127
+ ```bash
128
+ DEFAULT_CURSES_MINIMUM_CHAR_LEN = 40
129
+ DEFAULT_CURSES_MINIMUM_LINE_LEN = 1
130
+ ```
131
+ While leaving minimum 40 characters / 1 line for each host display by default. You can modify this by using -ww and -wh.
132
+
133
+
134
+ Use ```mssh --help``` for more info.
135
+
136
+ ```bash
137
+ usage: mssh [-h] [-u USERNAME] [-p PASSWORD] [-k [KEY]] [-uk] [-ea EXTRAARGS] [-11] [-f FILE] [-fs] [--scp] [-gm] [-t TIMEOUT] [-r REPEAT]
138
+ [-i INTERVAL] [--ipmi] [-mpre IPMI_INTERFACE_IP_PREFIX] [-pre INTERFACE_IP_PREFIX] [-q] [-ww WINDOW_WIDTH] [-wh WINDOW_HEIGHT]
139
+ [-sw] [-eo] [-no] [--no_env] [--env_file ENV_FILE] [-m MAX_CONNECTIONS] [-j] [--success_hosts] [-g] [-su | -nsu]
140
+ [-sh SKIP_HOSTS] [--store_config_file] [--debug] [-ci] [-V]
141
+ [hosts] [commands ...]
142
+
143
+ Run a command on multiple hosts, Use #HOST# or #HOSTNAME# to replace the host name in the command. Config file: /etc/multiSSH3.config.json
144
+
145
+ positional arguments:
146
+ hosts Hosts to run the command on, use "," to seperate hosts. (default: all)
147
+ commands the command to run on the hosts / the destination of the files #HOST# or #HOSTNAME# will be replaced with the host
148
+ name.
149
+
150
+ options:
151
+ -h, --help show this help message and exit
152
+ -u USERNAME, --username USERNAME
153
+ The general username to use to connect to the hosts. Will get overwrote by individual username@host if specified.
154
+ (default: None)
155
+ -p PASSWORD, --password PASSWORD
156
+ The password to use to connect to the hosts, (default: )
157
+ -k [KEY], --key [KEY], --identity [KEY]
158
+ The identity file to use to connect to the hosts. Implies --use_key. Specify a folder for program to search for a
159
+ key. Use option without value to use ~/.ssh/ (default: None)
160
+ -uk, --use_key Attempt to use public key file to connect to the hosts. (default: False)
161
+ -ea EXTRAARGS, --extraargs EXTRAARGS
162
+ Extra arguments to pass to the ssh / rsync / scp command. Put in one string for multiple arguments.Use "=" ! Ex.
163
+ -ea="--delete" (default: None)
164
+ -11, --oneonone Run one corresponding command on each host. (default: False)
165
+ -f FILE, --file FILE The file to be copied to the hosts. Use -f multiple times to copy multiple files
166
+ -fs, --file_sync Operate in file sync mode, sync path in <COMMANDS> from this machine to <HOSTS>. Treat --file <FILE> and
167
+ <COMMANDS> both as source as source and destination will be the same in this mode. (default: False)
168
+ --scp Use scp for copying files instead of rsync. Need to use this on windows. (default: False)
169
+ -gm, --gather_mode Gather files from the hosts instead of sending files to the hosts. Will send remote files specified in <FILE> to
170
+ local path specified in <COMMANDS> (default: False)
171
+ -t TIMEOUT, --timeout TIMEOUT
172
+ Timeout for each command in seconds (default: 600 (disabled))
173
+ -r REPEAT, --repeat REPEAT
174
+ Repeat the command for a number of times (default: 1)
175
+ -i INTERVAL, --interval INTERVAL
176
+ Interval between repeats in seconds (default: 0)
177
+ --ipmi Use ipmitool to run the command. (default: False)
178
+ -mpre IPMI_INTERFACE_IP_PREFIX, --ipmi_interface_ip_prefix IPMI_INTERFACE_IP_PREFIX
179
+ The prefix of the IPMI interfaces (default: )
180
+ -pre INTERFACE_IP_PREFIX, --interface_ip_prefix INTERFACE_IP_PREFIX
181
+ The prefix of the for the interfaces (default: None)
182
+ -q, -nw, --nowatch, --quiet
183
+ Quiet mode, no curses watch, only print the output. (default: False)
184
+ -ww WINDOW_WIDTH, --window_width WINDOW_WIDTH
185
+ The minimum character length of the curses window. (default: 40)
186
+ -wh WINDOW_HEIGHT, --window_height WINDOW_HEIGHT
187
+ The minimum line height of the curses window. (default: 5)
188
+ -sw, --single_window Use a single window for all hosts. (default: False)
189
+ -eo, --error_only Only print the error output. (default: False)
190
+ -no, --no_output Do not print the output. (default: False)
191
+ --no_env Do not load the command line environment variables. (default: False)
192
+ --env_file ENV_FILE The file to load the mssh file based environment variables from. ( Still work with --no_env ) (default:
193
+ /etc/profile.d/hosts.sh)
194
+ -m MAX_CONNECTIONS, --max_connections MAX_CONNECTIONS
195
+ Max number of connections to use (default: 4 * cpu_count)
196
+ -j, --json Output in json format. (default: False)
197
+ --success_hosts Output the hosts that succeeded in summary as wells. (default: False)
198
+ -g, --greppable, --table
199
+ Output in greppable format. (default: False)
200
+ -su, --skip_unreachable
201
+ Skip unreachable hosts. Note: Timedout Hosts are considered unreachable. Note: multiple command sequence will
202
+ still auto skip unreachable hosts. (default: False)
203
+ -nsu, --no_skip_unreachable
204
+ Do not skip unreachable hosts. Note: Timedout Hosts are considered unreachable. Note: multiple command sequence
205
+ will still auto skip unreachable hosts. (default: True)
206
+ -sh SKIP_HOSTS, --skip_hosts SKIP_HOSTS
207
+ Skip the hosts in the list. (default: None)
208
+ --store_config_file Store / generate the default config file from command line argument and current config at
209
+ /etc/multiSSH3.config.json
210
+ --debug Print debug information
211
+ -ci, --copy_id Copy the ssh id to the hosts
212
+ -V, --version show program's version number and exit
213
+ ```
214
+
215
+ Following document is generated courtesy of Mr.ChatGPT-o1 Preview:
216
+
217
+ # multissh
218
+
219
+ `multissh` is a powerful Python script that allows you to run commands on multiple hosts concurrently over SSH. It supports various features such as copying files, handling IP address ranges, using IPMI, and more. It's designed to simplify the management of multiple remote systems by automating command execution and file synchronization.
220
+
221
+ ## Table of Contents
222
+
223
+ - [multiSSH3](#multissh3)
224
+ - [multissh](#multissh)
225
+ - [Table of Contents](#table-of-contents)
226
+ - [Features](#features)
227
+ - [Basic Syntax](#basic-syntax)
228
+ - [Command-Line Options](#command-line-options)
229
+ - [Examples](#examples)
230
+ - [Running a Command on Multiple Hosts](#running-a-command-on-multiple-hosts)
231
+ - [Copying Files to Multiple Hosts](#copying-files-to-multiple-hosts)
232
+ - [Using Hostname Ranges](#using-hostname-ranges)
233
+ - [Using IPMI](#using-ipmi)
234
+ - [Using Password Authentication](#using-password-authentication)
235
+ - [Skipping Unreachable Hosts](#skipping-unreachable-hosts)
236
+ - [JSON Output](#json-output)
237
+ - [Quiet Mode](#quiet-mode)
238
+ - [Environment Variables](#environment-variables)
239
+ - [Notes](#notes)
240
+ - [License](#license)
241
+
242
+ ## Features
243
+
244
+ - **Concurrent Execution**: Run commands on multiple hosts concurrently with controlled parallelism.
245
+ - **File Transfer**: Copy files or synchronize directories to multiple hosts using `rsync` or `scp`.
246
+ - **Hostname Expansion**: Support for hostname ranges and wildcards for easy targeting of multiple hosts.
247
+ - **IPMI Support**: Execute IPMI commands on remote hosts.
248
+ - **Authentication**: Support for SSH password authentication and key-based authentication.
249
+ - **Custom SSH Options**: Pass extra arguments to SSH, `rsync`, or `scp` commands.
250
+ - **Skip Unreachable Hosts**: Option to skip hosts that are unreachable.
251
+ - **Output Formats**: Supports JSON and greppable output formats.
252
+ - **Interactive Mode**: Run interactive commands with curses-based UI for monitoring.
253
+ - **Quiet Mode**: Suppress output for cleaner automation scripts.
254
+
255
+ ### Basic Syntax
256
+
257
+ ```bash
258
+ mssh [options] <hosts> <commands>
259
+ ```
260
+
261
+ - `<hosts>`: Comma-separated list of target hosts. Supports ranges and wildcards.
262
+ - `<commands>`: Command(s) to execute on the target hosts.
263
+
264
+ ### Command-Line Options
265
+
266
+ | Short Option | Long Option | Description |
267
+ |--------------|---------------------------|-----------------------------------------------------------------------------------------------------------|
268
+ | `-u` | `--username` | Username for SSH connections. |
269
+ | `-ea` | `--extraargs` | Extra arguments for SSH/rsync/scp commands. |
270
+ | `-p` | `--password` | Password for SSH authentication. Requires `sshpass`. |
271
+ | `-11` | `--oneonone` | Run one command per host (commands and hosts lists must have the same length). |
272
+ | `-f` | `--file` | File(s) to copy to the hosts. Can be used multiple times. |
273
+ | | `--file_sync` | Synchronize directories instead of copying files. |
274
+ | | `--scp` | Use `scp` instead of `rsync` for file transfer. |
275
+ | `-t` | `--timeout` | Command execution timeout in seconds. |
276
+ | `-r` | `--repeat` | Number of times to repeat the command execution. |
277
+ | `-i` | `--interval` | Interval between command repetitions in seconds. |
278
+ | | `--ipmi` | Use IPMI to execute commands. |
279
+ | `-pre` | `--interface_ip_prefix` | IP prefix for interface selection. |
280
+ | `-q` | `--quiet` | Suppress output. |
281
+ | `-ww` | `--window_width` | Minimum character width for the curses window. |
282
+ | `-wh` | `--window_height` | Minimum line height for the curses window. |
283
+ | `-sw` | `--single_window` | Use a single window for all hosts in curses mode. |
284
+ | `-eo` | `--error_only` | Only display error outputs. |
285
+ | `-no` | `--nooutput` | Do not print any output. |
286
+ | | `--no_env` | Do not load environment variables from files. |
287
+ | | `--env_file` | Specify a custom environment file. |
288
+ | `-m` | `--maxconnections` | Maximum number of concurrent SSH connections. |
289
+ | `-j` | `--json` | Output results in JSON format. |
290
+ | | `--success_hosts` | Also display hosts where commands succeeded. |
291
+ | `-g` | `--greppable` | Output results in a greppable format. |
292
+ | `-nw` | `--nowatch` | Do not use curses mode; use simple output instead. |
293
+ | `-su` | `--skipunreachable` | Skip hosts that are unreachable. |
294
+ | `-sh` | `--skiphosts` | Comma-separated list of hosts to skip. |
295
+ | `-V` | `--version` | Display the script version and exit. |
296
+
297
+ ## Examples
298
+
299
+ ### Running a Command on Multiple Hosts
300
+
301
+ ```bash
302
+ mssh "host1,host2,host3" "uptime"
303
+ ```
304
+
305
+ This command runs `uptime` on `host1`, `host2`, and `host3`.
306
+
307
+ ### Copying Files to Multiple Hosts
308
+
309
+ ```bash
310
+ mssh -f "/path/to/local/file.txt" "host1,host2,host3" "/remote/path/"
311
+ ```
312
+
313
+ This command copies `file.txt` to `/remote/path/` on the specified hosts.
314
+
315
+ ### Using Hostname Ranges
316
+
317
+ ```bash
318
+ mssh "host[01-05]" "hostname"
319
+ ```
320
+
321
+ This expands to `host01`, `host02`, `host03`, `host04`, `host05` and runs `hostname` on each.
322
+
323
+ ### Using IPMI
324
+
325
+ ```bash
326
+ mssh --ipmi "192.168.1.[100-105]" "chassis power status"
327
+ ```
328
+
329
+ Runs `ipmitool chassis power status` on the specified IPMI interfaces.
330
+
331
+ ### Using Password Authentication
332
+
333
+ ```bash
334
+ mssh -p "yourpassword" "host1,host2" "whoami"
335
+ ```
336
+
337
+ Uses `sshpass` to provide the password for SSH authentication.
338
+
339
+ ### Skipping Unreachable Hosts
340
+
341
+ ```bash
342
+ mssh -su "host1,host2,host3" "date"
343
+ ```
344
+
345
+ Skips hosts that are unreachable during execution.
346
+
347
+ ### JSON Output
348
+
349
+ ```bash
350
+ mssh -j "host1,host2" "uname -a"
351
+ ```
352
+
353
+ Outputs the results in JSON format, suitable for parsing.
354
+
355
+ ### Quiet Mode
356
+
357
+ ```bash
358
+ mssh -q "host1,host2" "ls /nonexistent"
359
+ ```
360
+
361
+ Suppresses all output, useful for scripts where you only care about exit codes.
362
+
363
+ ## Environment Variables
364
+
365
+ - The script can load environment variables from a file (default: `/etc/profile.d/hosts.sh`) to resolve hostnames.
366
+ - Use the `--env_file` option to specify a custom environment file.
367
+ - Use `--no_env` to prevent loading any environment variables from files.
368
+
369
+ ## Notes
370
+ - **Dependencies**: Requires Python 3, `sshpass` (if using password authentication), and standard Unix utilities like `ssh`, `scp`, and `rsync`.
371
+ - **Signal Handling**: Supports graceful termination with `Ctrl+C`.
372
+
373
+ ## License
374
+
375
+ This script is provided "as is" without any warranty. Use it at your own risk.
376
+
377
+ ---