multiSSH3 4.75__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.
- multiSSH3-4.75.dist-info/LICENSE +674 -0
- multiSSH3-4.75.dist-info/METADATA +305 -0
- multiSSH3-4.75.dist-info/RECORD +7 -0
- multiSSH3-4.75.dist-info/WHEEL +5 -0
- multiSSH3-4.75.dist-info/entry_points.txt +6 -0
- multiSSH3-4.75.dist-info/top_level.txt +1 -0
- multiSSH3.py +1509 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: multiSSH3
|
|
3
|
+
Version: 4.75
|
|
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
|
+
|
|
17
|
+
# multiSSH3
|
|
18
|
+
A script that is able to issue commands to multiple hosts while monitoring their progress.
|
|
19
|
+
Can be used in bash scripts for automation actions.
|
|
20
|
+
Also able to be imported and / or use with Flexec SSH Backend to perform cluster automation actions.
|
|
21
|
+
|
|
22
|
+
By defualt reads bash env variables for hostname aliases. Also able to read
|
|
23
|
+
```
|
|
24
|
+
DEFAULT_ENV_FILE = '/etc/profile.d/hosts.sh'
|
|
25
|
+
```
|
|
26
|
+
as hostname aliases.
|
|
27
|
+
|
|
28
|
+
For example:
|
|
29
|
+
```
|
|
30
|
+
export all='192.168.1-2.1-64'
|
|
31
|
+
multiSSH3.py all 'echo hi'
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
It is also able to recognize ip blocks / number blocks / hex blocks / character blocks directly.
|
|
35
|
+
|
|
36
|
+
For example:
|
|
37
|
+
```
|
|
38
|
+
multiSSH3.py testrig[1-10] lsblk
|
|
39
|
+
multiSSH3.py ww[a-c],10.100.0.* 'cat /etc/fstab' 'sed -i "/lustre/d' /etc/fstab' 'cat /etc/fstab'
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
It also supports interactive inputs. ( and able to async boardcast to all supplied hosts )
|
|
43
|
+
```
|
|
44
|
+
multiSSH3.py www bash
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
By default, it will try to fit everything inside your window.
|
|
48
|
+
```
|
|
49
|
+
DEFAULT_CURSES_MINIMUM_CHAR_LEN = 40
|
|
50
|
+
DEFAULT_CURSES_MINIMUM_LINE_LEN = 1
|
|
51
|
+
```
|
|
52
|
+
While leaving minimum 40 characters / 1 line for each host display by default. You can modify this by using -ww and -wh.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
Use ```multiSSH3.py --help``` for more info.
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
usage: mssh [-h] [-u USERNAME] [-ea EXTRAARGS] [-p PASSWORD] [-11] [-f FILE] [--file_sync] [--scp] [-t TIMEOUT] [-r REPEAT] [-i INTERVAL] [--ipmi]
|
|
59
|
+
[-pre INTERFACE_IP_PREFIX] [-q] [-ww WINDOW_WIDTH] [-wh WINDOW_HEIGHT] [-sw] [-eo] [-no] [--no_env] [--env_file ENV_FILE] [-m MAXCONNECTIONS] [-j]
|
|
60
|
+
[--success_hosts] [-g] [-nw] [-su] [-sh SKIPHOSTS] [-V]
|
|
61
|
+
hosts commands [commands ...]
|
|
62
|
+
|
|
63
|
+
Run a command on multiple hosts, Use #HOST# or #HOSTNAME# to replace the host name in the command
|
|
64
|
+
|
|
65
|
+
positional arguments:
|
|
66
|
+
hosts Hosts to run the command on, use "," to seperate hosts
|
|
67
|
+
commands the command to run on the hosts / the destination of the files #HOST# or #HOSTNAME# will be replaced with the host name.
|
|
68
|
+
|
|
69
|
+
options:
|
|
70
|
+
-h, --help show this help message and exit
|
|
71
|
+
-u USERNAME, --username USERNAME
|
|
72
|
+
The general username to use to connect to the hosts. Will get overwrote by individual username@host if specified. (default: None)
|
|
73
|
+
-ea EXTRAARGS, --extraargs EXTRAARGS
|
|
74
|
+
Extra arguments to pass to the ssh / rsync / scp command. Put in one string for multiple arguments.Use "=" ! Ex. -ea="--delete" (default:
|
|
75
|
+
None)
|
|
76
|
+
-p PASSWORD, --password PASSWORD
|
|
77
|
+
The password to use to connect to the hosts, (default: hermes)
|
|
78
|
+
-11, --oneonone Run one corresponding command on each host. (default: False)
|
|
79
|
+
-f FILE, --file FILE The file to be copied to the hosts. Use -f multiple times to copy multiple files
|
|
80
|
+
--file_sync Operate in file sync mode, sync path in <COMMANDS> from this machine to <HOSTS>. Treat --file <FILE> and <COMMANDS> both as source as source
|
|
81
|
+
and destination will be the same in this mode. (default: False)
|
|
82
|
+
--scp Use scp for copying files instead of rsync. Need to use this on windows. (default: False)
|
|
83
|
+
-t TIMEOUT, --timeout TIMEOUT
|
|
84
|
+
Timeout for each command in seconds (default: 0 (disabled))
|
|
85
|
+
-r REPEAT, --repeat REPEAT
|
|
86
|
+
Repeat the command for a number of times (default: 1)
|
|
87
|
+
-i INTERVAL, --interval INTERVAL
|
|
88
|
+
Interval between repeats in seconds (default: 0)
|
|
89
|
+
--ipmi Use ipmitool to run the command. (default: False)
|
|
90
|
+
-pre INTERFACE_IP_PREFIX, --interface_ip_prefix INTERFACE_IP_PREFIX
|
|
91
|
+
The prefix of the for the interfaces (default: None)
|
|
92
|
+
-q, --quiet Quiet mode, no curses, only print the output. (default: False)
|
|
93
|
+
-ww WINDOW_WIDTH, --window_width WINDOW_WIDTH
|
|
94
|
+
The minimum character length of the curses window. (default: 40)
|
|
95
|
+
-wh WINDOW_HEIGHT, --window_height WINDOW_HEIGHT
|
|
96
|
+
The minimum line height of the curses window. (default: 1)
|
|
97
|
+
-sw, --single_window Use a single window for all hosts. (default: False)
|
|
98
|
+
-eo, --error_only Only print the error output. (default: False)
|
|
99
|
+
-no, --nooutput Do not print the output. (default: False)
|
|
100
|
+
--no_env Do not load the environment variables. (default: False)
|
|
101
|
+
--env_file ENV_FILE The file to load the environment variables from. (default: /etc/profile.d/hosts.sh)
|
|
102
|
+
-m MAXCONNECTIONS, --maxconnections MAXCONNECTIONS
|
|
103
|
+
Max number of connections to use (default: 4 * cpu_count)
|
|
104
|
+
-j, --json Output in json format. (default: False)
|
|
105
|
+
--success_hosts Output the hosts that succeeded in summary as wells. (default: False)
|
|
106
|
+
-g, --greppable Output in greppable format. (default: False)
|
|
107
|
+
-nw, --nowatch Do not watch the output in curses modem, Use \r. Not implemented yet. (default: False)
|
|
108
|
+
-su, --skipunreachable
|
|
109
|
+
Skip unreachable hosts while using --repeat. Note: Timedout Hosts are considered unreachable. Note: multiple command sequence will still auto
|
|
110
|
+
skip unreachable hosts. (default: False)
|
|
111
|
+
-sh SKIPHOSTS, --skiphosts SKIPHOSTS
|
|
112
|
+
Skip the hosts in the list. (default: )
|
|
113
|
+
-V, --version show program's version number and exit
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Following document is generated courtesy of Mr.ChatGPT-o1 Preview:
|
|
117
|
+
|
|
118
|
+
# multissh
|
|
119
|
+
|
|
120
|
+
`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.
|
|
121
|
+
|
|
122
|
+
## Table of Contents
|
|
123
|
+
|
|
124
|
+
- [Features](#features)
|
|
125
|
+
- [Installation](#installation)
|
|
126
|
+
- [Usage](#usage)
|
|
127
|
+
- [Basic Syntax](#basic-syntax)
|
|
128
|
+
- [Command-Line Options](#command-line-options)
|
|
129
|
+
- [Examples](#examples)
|
|
130
|
+
- [Running a Command on Multiple Hosts](#running-a-command-on-multiple-hosts)
|
|
131
|
+
- [Copying Files to Multiple Hosts](#copying-files-to-multiple-hosts)
|
|
132
|
+
- [Using Hostname Ranges](#using-hostname-ranges)
|
|
133
|
+
- [Using IPMI](#using-ipmi)
|
|
134
|
+
- [Using Password Authentication](#using-password-authentication)
|
|
135
|
+
- [Skipping Unreachable Hosts](#skipping-unreachable-hosts)
|
|
136
|
+
- [JSON Output](#json-output)
|
|
137
|
+
- [Quiet Mode](#quiet-mode)
|
|
138
|
+
- [Environment Variables](#environment-variables)
|
|
139
|
+
- [Notes](#notes)
|
|
140
|
+
- [License](#license)
|
|
141
|
+
|
|
142
|
+
## Features
|
|
143
|
+
|
|
144
|
+
- **Concurrent Execution**: Run commands on multiple hosts concurrently with controlled parallelism.
|
|
145
|
+
- **File Transfer**: Copy files or synchronize directories to multiple hosts using `rsync` or `scp`.
|
|
146
|
+
- **Hostname Expansion**: Support for hostname ranges and wildcards for easy targeting of multiple hosts.
|
|
147
|
+
- **IPMI Support**: Execute IPMI commands on remote hosts.
|
|
148
|
+
- **Authentication**: Support for SSH password authentication and key-based authentication.
|
|
149
|
+
- **Custom SSH Options**: Pass extra arguments to SSH, `rsync`, or `scp` commands.
|
|
150
|
+
- **Skip Unreachable Hosts**: Option to skip hosts that are unreachable.
|
|
151
|
+
- **Output Formats**: Supports JSON and greppable output formats.
|
|
152
|
+
- **Interactive Mode**: Run interactive commands with curses-based UI for monitoring.
|
|
153
|
+
- **Quiet Mode**: Suppress output for cleaner automation scripts.
|
|
154
|
+
|
|
155
|
+
## Installation
|
|
156
|
+
|
|
157
|
+
1. **Clone the Repository**
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
git clone https://github.com/yourusername/multissh.git
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
2. **Navigate to the Directory**
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
cd multissh
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
3. **Make the Script Executable**
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
chmod +x multissh.py
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
4. **Install Dependencies**
|
|
176
|
+
|
|
177
|
+
Ensure you have Python 3 and the required modules installed. You may need to install `curses` and `ipaddress` modules if they are not already available.
|
|
178
|
+
|
|
179
|
+
## Usage
|
|
180
|
+
|
|
181
|
+
### Basic Syntax
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
./multissh.py [options] <hosts> <commands>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
- `<hosts>`: Comma-separated list of target hosts. Supports ranges and wildcards.
|
|
188
|
+
- `<commands>`: Command(s) to execute on the target hosts.
|
|
189
|
+
|
|
190
|
+
### Command-Line Options
|
|
191
|
+
|
|
192
|
+
| Short Option | Long Option | Description |
|
|
193
|
+
|--------------|---------------------------|-----------------------------------------------------------------------------------------------------------|
|
|
194
|
+
| `-u` | `--username` | Username for SSH connections. |
|
|
195
|
+
| `-ea` | `--extraargs` | Extra arguments for SSH/rsync/scp commands. |
|
|
196
|
+
| `-p` | `--password` | Password for SSH authentication. Requires `sshpass`. |
|
|
197
|
+
| `-11` | `--oneonone` | Run one command per host (commands and hosts lists must have the same length). |
|
|
198
|
+
| `-f` | `--file` | File(s) to copy to the hosts. Can be used multiple times. |
|
|
199
|
+
| | `--file_sync` | Synchronize directories instead of copying files. |
|
|
200
|
+
| | `--scp` | Use `scp` instead of `rsync` for file transfer. |
|
|
201
|
+
| `-t` | `--timeout` | Command execution timeout in seconds. |
|
|
202
|
+
| `-r` | `--repeat` | Number of times to repeat the command execution. |
|
|
203
|
+
| `-i` | `--interval` | Interval between command repetitions in seconds. |
|
|
204
|
+
| | `--ipmi` | Use IPMI to execute commands. |
|
|
205
|
+
| `-pre` | `--interface_ip_prefix` | IP prefix for interface selection. |
|
|
206
|
+
| `-q` | `--quiet` | Suppress output. |
|
|
207
|
+
| `-ww` | `--window_width` | Minimum character width for the curses window. |
|
|
208
|
+
| `-wh` | `--window_height` | Minimum line height for the curses window. |
|
|
209
|
+
| `-sw` | `--single_window` | Use a single window for all hosts in curses mode. |
|
|
210
|
+
| `-eo` | `--error_only` | Only display error outputs. |
|
|
211
|
+
| `-no` | `--nooutput` | Do not print any output. |
|
|
212
|
+
| | `--no_env` | Do not load environment variables from files. |
|
|
213
|
+
| | `--env_file` | Specify a custom environment file. |
|
|
214
|
+
| `-m` | `--maxconnections` | Maximum number of concurrent SSH connections. |
|
|
215
|
+
| `-j` | `--json` | Output results in JSON format. |
|
|
216
|
+
| | `--success_hosts` | Also display hosts where commands succeeded. |
|
|
217
|
+
| `-g` | `--greppable` | Output results in a greppable format. |
|
|
218
|
+
| `-nw` | `--nowatch` | Do not use curses mode; use simple output instead. |
|
|
219
|
+
| `-su` | `--skipunreachable` | Skip hosts that are unreachable. |
|
|
220
|
+
| `-sh` | `--skiphosts` | Comma-separated list of hosts to skip. |
|
|
221
|
+
| `-V` | `--version` | Display the script version and exit. |
|
|
222
|
+
|
|
223
|
+
## Examples
|
|
224
|
+
|
|
225
|
+
### Running a Command on Multiple Hosts
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
./multissh.py "host1,host2,host3" "uptime"
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
This command runs `uptime` on `host1`, `host2`, and `host3`.
|
|
232
|
+
|
|
233
|
+
### Copying Files to Multiple Hosts
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
./multissh.py -f "/path/to/local/file.txt" "host1,host2,host3" "/remote/path/"
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
This command copies `file.txt` to `/remote/path/` on the specified hosts.
|
|
240
|
+
|
|
241
|
+
### Using Hostname Ranges
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
./multissh.py "host[01-05]" "hostname"
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
This expands to `host01`, `host02`, `host03`, `host04`, `host05` and runs `hostname` on each.
|
|
248
|
+
|
|
249
|
+
### Using IPMI
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
./multissh.py --ipmi "192.168.1.[100-105]" "chassis power status"
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Runs `ipmitool chassis power status` on the specified IPMI interfaces.
|
|
256
|
+
|
|
257
|
+
### Using Password Authentication
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
./multissh.py -p "yourpassword" "host1,host2" "whoami"
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Uses `sshpass` to provide the password for SSH authentication.
|
|
264
|
+
|
|
265
|
+
### Skipping Unreachable Hosts
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
./multissh.py -su "host1,host2,host3" "date"
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Skips hosts that are unreachable during execution.
|
|
272
|
+
|
|
273
|
+
### JSON Output
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
./multissh.py -j "host1,host2" "uname -a"
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Outputs the results in JSON format, suitable for parsing.
|
|
280
|
+
|
|
281
|
+
### Quiet Mode
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
./multissh.py -q "host1,host2" "ls /nonexistent"
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Suppresses all output, useful for scripts where you only care about exit codes.
|
|
288
|
+
|
|
289
|
+
## Environment Variables
|
|
290
|
+
|
|
291
|
+
- The script can load environment variables from a file (default: `/etc/profile.d/hosts.sh`) to resolve hostnames.
|
|
292
|
+
- Use the `--env_file` option to specify a custom environment file.
|
|
293
|
+
- Use `--no_env` to prevent loading any environment variables from files.
|
|
294
|
+
|
|
295
|
+
## Notes
|
|
296
|
+
|
|
297
|
+
- **SSH Configuration**: The script modifies `~/.ssh/config` to disable `StrictHostKeyChecking`. Ensure this is acceptable in your environment.
|
|
298
|
+
- **Dependencies**: Requires Python 3, `sshpass` (if using password authentication), and standard Unix utilities like `ssh`, `scp`, and `rsync`.
|
|
299
|
+
- **Signal Handling**: Supports graceful termination with `Ctrl+C`.
|
|
300
|
+
|
|
301
|
+
## License
|
|
302
|
+
|
|
303
|
+
This script is provided "as is" without any warranty. Use it at your own risk.
|
|
304
|
+
|
|
305
|
+
---
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
multiSSH3.py,sha256=4arZmvbOpX6cwHYdaHu7Y_Jz8sUDhfMqkgn-iijX3qc,72292
|
|
2
|
+
multiSSH3-4.75.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
3
|
+
multiSSH3-4.75.dist-info/METADATA,sha256=dSPPX26CnHQI5gKHa0U-wYvax_2DzlkBC2DlBSGvMjI,15482
|
|
4
|
+
multiSSH3-4.75.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
|
5
|
+
multiSSH3-4.75.dist-info/entry_points.txt,sha256=xi2rWWNfmHx6gS8Mmx0rZL2KZz6XWBYP3DWBpWAnnZ0,143
|
|
6
|
+
multiSSH3-4.75.dist-info/top_level.txt,sha256=tUwttxlnpLkZorSsroIprNo41lYSxjd2ASuL8-EJIJw,10
|
|
7
|
+
multiSSH3-4.75.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
multiSSH3
|