Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: joknarf/ssh-para
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.3.11
Choose a base ref
...
head repository: joknarf/ssh-para
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref

Commits on Jul 9, 2024

  1. Copy the full SHA
    cdba964 View commit details
  2. resolve warn/count failed

    joknarf committed Jul 9, 2024
    Copy the full SHA
    11ff9c2 View commit details
  3. curses_kill

    joknarf committed Jul 9, 2024
    Copy the full SHA
    409daca View commit details

Commits on Jul 11, 2024

  1. handler SIGPIPE

    joknarf committed Jul 11, 2024
    Copy the full SHA
    145708a View commit details

Commits on Jul 13, 2024

  1. logs enh

    joknarf committed Jul 13, 2024
    Copy the full SHA
    f47a956 View commit details
  2. Merge pull request #11 from joknarf/log_view

    curses.raw() to handle ctrl-c / logging refactor
    joknarf authored Jul 13, 2024
    Copy the full SHA
    ec338e7 View commit details
  3. README autocompletion

    joknarf committed Jul 13, 2024
    Copy the full SHA
    0322d00 View commit details
  4. Copy the full SHA
    832c444 View commit details
  5. fix f string py38

    joknarf committed Jul 13, 2024
    Copy the full SHA
    f5e80f6 View commit details

Commits on Jul 23, 2024

  1. typing check

    joknarf committed Jul 23, 2024
    Copy the full SHA
    b8eab32 View commit details
  2. fix pyright

    joknarf committed Jul 23, 2024
    Copy the full SHA
    0843f89 View commit details
  3. add typing hint

    joknarf committed Jul 23, 2024
    Copy the full SHA
    8beb9a6 View commit details
  4. black code

    joknarf committed Jul 23, 2024
    Copy the full SHA
    0b65d4c View commit details

Commits on Jul 28, 2024

  1. args Namespace

    joknarf committed Jul 28, 2024
    Copy the full SHA
    381b9d3 View commit details

Commits on Sep 7, 2024

  1. filter empty hosts

    joknarf committed Sep 7, 2024
    Copy the full SHA
    ef00138 View commit details
  2. Merge pull request #12 from joknarf/typing

    Typing hints
    joknarf authored Sep 7, 2024
    Copy the full SHA
    23bc8f0 View commit details
  3. Copy the full SHA
    44c42e2 View commit details
  4. Copy the full SHA
    f3f4bbd View commit details
  5. Merge pull request #13 from joknarf/cols_trunc

    truncate commands/logs to screen width
    joknarf authored Sep 7, 2024
    Copy the full SHA
    5d13a41 View commit details

Commits on Sep 14, 2024

  1. multiline command on 1 line

    joknarf committed Sep 14, 2024
    Copy the full SHA
    3a4e442 View commit details

Commits on Oct 19, 2024

  1. resolve done in Job threads

    joknarf committed Oct 19, 2024
    Copy the full SHA
    3afdf67 View commit details
  2. black reformat

    joknarf committed Oct 19, 2024
    Copy the full SHA
    49c52e8 View commit details
  3. Merge pull request #14 from joknarf/resolve_thread

    dns resolve done in Job threads
    joknarf authored Oct 19, 2024
    Copy the full SHA
    4d874fb View commit details
  4. status not truncated

    joknarf committed Oct 19, 2024
    Copy the full SHA
    b5717b2 View commit details
  5. status - separator

    joknarf committed Oct 19, 2024
    Copy the full SHA
    fc5602b View commit details

Commits on Nov 26, 2024

  1. -f - reads from stdin

    joknarf committed Nov 26, 2024
    Copy the full SHA
    9a3ea2d View commit details

Commits on Dec 21, 2024

  1. Copy the full SHA
    96a6aca View commit details
  2. link to run-para

    joknarf authored Dec 21, 2024
    Copy the full SHA
    aeee2ef View commit details
Showing with 466 additions and 294 deletions.
  1. +56 −27 README.md
  2. +1 −0 pyproject.toml
  3. +409 −267 ssh_para/ssh_para.py
83 changes: 56 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@ Parallel SSH jobs manager CLI (alternative to parallel-ssh)
* Keep all output in log files
* Interactive pause/resume/abort jobs, kill stuck ssh connection interactively.

Take a look at [run-para](https://github.com/joknarf/run-para) if you need to run parallel jobs parameterized

![ssh-para3](https://github.com/joknarf/ssh-para/assets/10117818/aef84de2-d15c-44f6-b6ff-74dc5f6f7b08)


@@ -22,54 +24,77 @@ pip install ssh-para
```
By default, `ssh-para` uses Nerd Fonts glyphs, modern terminals can now render the glyphs without installing specific font (the symbols can be overridden with SSHP_SYM_* environment variables, see below)

# quick start

```
Run command on multiple hosts:
$ ssh-para -H host1 host2 host3 -- echo connection ok
Review last run results:
$ ssh-para -l
Review hosts statuses for last run:
$ ssh-para -L *.status
View failed hosts list:
$ ssh-para -L failed.status
Show output of command on all hosts:
$ ssh-para -L *.out
Show output of command for failed hosts:
$ ssh-para -L *.failed
Show output of command for host1:
$ ssh-para -L host1.out
```

# usage
```
ssh-para -h
```
```
usage: ssh_para.py [-h] [-p PARALLEL] [-j JOB] [-d DIRLOG] [-f HOSTSFILE | -H HOSTS [HOSTS ...]]
[-D DELAY] [-s SCRIPT] [-a ARGS [ARGS ...]] [-t TIMEOUT] [-r] [-v] [-l]
[-L [LOGS ...]] [-m MAXDOTS] [-V]
[ssh_args ...]
usage: ssh-para [-h] [-V] [-j JOB] [-d DIRLOG] [-m MAXDOTS] [-p PARALLEL] [-t TIMEOUT] [-r] [-v] [-D DELAY]
[-f HOSTSFILE | -H HOSTS [HOSTS ...] | -C {bash,zsh,powershell} | -l | -L LOGS [LOGS ...]] [-s SCRIPT]
[-a ARGS [ARGS ...]]
[ssh_args ...]
ssh-para vX.X.X
ssh-para v1.ssh-para.dev
positional arguments:
ssh_args
options:
-h, --help show this help message and exit
-p PARALLEL, --parallel PARALLEL
parallelism (default 4)
-V, --version ssh-para version
-j JOB, --job JOB Job name added subdir to dirlog
-d DIRLOG, --dirlog DIRLOG
directory for ouput log files (~/.ssh-para)
directory for ouput log files (default: ~/.ssh-para)
-m MAXDOTS, --maxdots MAXDOTS
hostname domain displaylevel (default:1 => short hostname, -1 => fqdn)
-p PARALLEL, --parallel PARALLEL
parallelism (default 4)
-t TIMEOUT, --timeout TIMEOUT
timeout of each job
-r, --resolve resolve fqdn in SSHP_DOMAINS
-v, --verbose verbose display (fqdn + line for last output)
-D DELAY, --delay DELAY
initial delay in seconds between ssh commands (default=0.3s)
-f HOSTSFILE, --hostsfile HOSTSFILE
hosts list file
-H HOSTS [HOSTS ...], --hosts HOSTS [HOSTS ...]
hosts list
-D DELAY, --delay DELAY
initial delay in seconds between ssh commands (default=0.3s)
-C {bash,zsh,powershell}, --completion {bash,zsh,powershell}
autocompletion shell code to source
-l, --list list ssh-para results/log directories
-L LOGS [LOGS ...], --logs LOGS [LOGS ...]
get latest/current ssh-para run logs
-L[<runid>/]*.out : all hosts outputs
-L[<runid>/]<host>.out : command output of host
-L[<runid>/]*.<status> : command output of hosts <status>
-L[<runid>/]*.status : hosts lists with status
-L[<runid>/]<status>.status: <status> hosts list
-L[<runid>/]hosts.list : list of hosts used to connect (resolved if -r)
default <runid> is latest ssh-para run (use -j <job> -d <dir> to access logs if used for run)
<status>: [success,failed,timeout,killed,aborted]
-s SCRIPT, --script SCRIPT
script to execute
-a ARGS [ARGS ...], --args ARGS [ARGS ...]
script arguments
-t TIMEOUT, --timeout TIMEOUT
timeout of each job
-r, --resolve resolve fqdn in SSHP_DOMAINS
-v, --verbose verbose display (fqdn + line for last output)
-l, --list list ssh-para results/log directories
-L [LOGS ...], --logs [LOGS ...]
get latest/current ssh-para run logs
-L=* : all logs
-L=*.out : all hosts outputs
-L=*.success : output of success hosts
-L=*.failed : output of failed hosts
-L=<host>.* : logs for host
-L <logid>/* : logs for logid (from ssh-para --list)
-m MAXDOTS, --maxdots MAXDOTS
hostname domain displaylevel (default:0 => short hostname)
-V, --version ssh-para version
```
During run, use :
* k: to kill ssh command held by a thread (but remote command can still be running on remote host)
@@ -86,6 +111,10 @@ Environment variables:
* SSHP_SYM_PROG: Symbol character for progress bar fill (default: "\u25a0")
* SSHP_SYM_RES: Symbol character before ssh output line (default: "\u25b6")

Activate autocompletion:
* `. <(ssh-para -C bash)`
* `ssh-para -C powershell | Out-String | Invoke-Expression`

# Example

Patch redhat family hosts:
@@ -114,4 +143,4 @@ SSHP_DOMAINS="domain1.com domain2.com" ssh-para -r -H host1 host2 -- echo connec
* if you are using ssh ProxyJump server to reach hosts, you may need to tweak the sshd MaxStartups setting on the ssh Proxy server with high parallelism
* *when ssh-para starts, a delay of 0.3 seconds is applied between threads starting ssh jobs to avoid flooding, (can be tweaked with -D <delay>)*
* if you are using remote connexion to launch the ssh-para, use `screen` to launch ssh-para, as if you lose your connection, ssh-para will be still running and you can re-attach to `screen` to continue follow-up.
* Be very carefull when launching massive commands on servers... Always first test on non production.
* Be very carefull when launching massive commands on servers... Always first test on non production.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ description = "Interactive Parallel SSH jobs manager"
dependencies = [
"colorama",
"dataclasses>=0.6; python_version < '3.7'",
"argcomplete>=3.0.4",
"windows-curses>=2.3.3; platform_system == 'Windows'",
]
dynamic=["version"]
Loading