ssh-para


Namessh-para JSON
Version 1.4.5 PyPI version JSON
download
home_pageNone
SummaryInteractive Parallel SSH jobs manager
upload_time2024-09-14 09:06:51
maintainerFranck Jouvanceau
docs_urlNone
authorFranck Jouvanceau
requires_python>=3.6
licenseMIT License Copyright (c) 2024 joknarf Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords ssh cli parallel jobs
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Pypi version](https://img.shields.io/pypi/v/ssh-para.svg)](https://pypi.org/project/ssh-para/)
![example](https://github.com/joknarf/ssh-para/actions/workflows/python-publish.yml/badge.svg)
[![Licence](https://img.shields.io/badge/licence-MIT-blue.svg)](https://shields.io/)
[![](https://pepy.tech/badge/ssh-para)](https://pepy.tech/project/ssh-para)
[![Python versions](https://img.shields.io/badge/python-3.6+-blue.svg)](https://shields.io/)



# ssh-para
Parallel SSH jobs manager CLI (alternative to parallel-ssh)
* POSIX/Linux/MacOS/Windows compatible (with openssh client installed)
* Launch parallel ssh jobs/scripts on remote hosts, with interactive display of the running commands outputs
* Keep all output in log files
* Interactive pause/resume/abort jobs, kill stuck ssh connection interactively.

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


# installation
```shell
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 [-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 v1.ssh-para.dev

positional arguments:
  ssh_args

options:
  -h, --help            show this help message and exit
  -V, --version         ssh-para version
  -j JOB, --job JOB     Job name added subdir to dirlog
  -d DIRLOG, --dirlog DIRLOG
                        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
  -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
```    
During run, use :
* k: to kill ssh command held by a thread (but remote command can still be running on remote host)
* p: pause all remaining jobs to be scheduled
* r: resume scheduling of jobs
* a: abort all remaining jobs
* ctrl-c: stop all/exit (but remote commands launched by ssh can still be running on remote servers)

Environment variables:
* SSHP_OPTS: ssh default options (Eg: "-F /home/user/.ssh/myconfig")
* SSHP_DOMAINS: dns domains to search when short hostname given (with -r/--resolve option)
* SSHP_SYM_BEG: Symbol character for begin decorative (default: "\ue0b4")
* SSHP_SYM_END: Symbol character for end decorative (default: "\ue0b6")
* 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:
```shell
ssh-para -p 20 -f hostlist.txt -- 'sudo yum update -y;sudo shutdown -r +1'
```
Use specific ssh options / config (everything after `--` will be passed to ssh command as is):
```shell
ssh-para -p 20 -H host1 host2 -- -F ~/.ssh/myconfig echo connect ok
```
Launch local script with argument on remote hosts:
```shell
ssh-para -p 20 -f hosts.txt -s ./myscript -a status
```
Extend limited resolv.conf search domains (try to resolve host in each domain, first resolved in the domain list is used as fqdn):
```shell
SSHP_DOMAINS="domain1.com domain2.com" ssh-para -r -H host1 host2 -- echo connect ok
```

# Tips

* ssh-para uses ssh BatchMode, no interactive password/passphrase will be asked, so you need to have a ssh authorized key to connect to servers (ssh-agent...)
* you need to configure your ssh for StrictHostKeyChecking/UserKnownHostsFile if you need to connect to unknown servers
* to connect as different user use ssh -l option or define everything in your ssh config file
  * *you can use user@host as hostname but not if you need to resolve host (-r/--resolve)*
* 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.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ssh-para",
    "maintainer": "Franck Jouvanceau",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "ssh, cli, parallel, jobs",
    "author": "Franck Jouvanceau",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/c9/46/e323074a43965fa470776b13fe29a235da81d2bcb9e6b53f8a8671f66207/ssh_para-1.4.5.tar.gz",
    "platform": null,
    "description": "[![Pypi version](https://img.shields.io/pypi/v/ssh-para.svg)](https://pypi.org/project/ssh-para/)\n![example](https://github.com/joknarf/ssh-para/actions/workflows/python-publish.yml/badge.svg)\n[![Licence](https://img.shields.io/badge/licence-MIT-blue.svg)](https://shields.io/)\n[![](https://pepy.tech/badge/ssh-para)](https://pepy.tech/project/ssh-para)\n[![Python versions](https://img.shields.io/badge/python-3.6+-blue.svg)](https://shields.io/)\n\n\n\n# ssh-para\nParallel SSH jobs manager CLI (alternative to parallel-ssh)\n* POSIX/Linux/MacOS/Windows compatible (with openssh client installed)\n* Launch parallel ssh jobs/scripts on remote hosts, with interactive display of the running commands outputs\n* Keep all output in log files\n* Interactive pause/resume/abort jobs, kill stuck ssh connection interactively.\n\n![ssh-para3](https://github.com/joknarf/ssh-para/assets/10117818/aef84de2-d15c-44f6-b6ff-74dc5f6f7b08)\n\n\n# installation\n```shell\npip install ssh-para\n```\nBy 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)\n\n# quick start\n\n```\nRun command on multiple hosts:\n$ ssh-para -H host1 host2 host3 -- echo connection ok\nReview last run results:\n$ ssh-para -l\nReview hosts statuses for last run:\n$ ssh-para -L *.status\nView failed hosts list:\n$ ssh-para -L failed.status\nShow output of command on all hosts:\n$ ssh-para -L *.out\nShow output of command for failed hosts:\n$ ssh-para -L *.failed\nShow output of command for host1:\n$ ssh-para -L host1.out\n```\n\n# usage\n```\nssh-para -h\n```\n```\nusage: ssh-para [-h] [-V] [-j JOB] [-d DIRLOG] [-m MAXDOTS] [-p PARALLEL] [-t TIMEOUT] [-r] [-v] [-D DELAY]\n                [-f HOSTSFILE | -H HOSTS [HOSTS ...] | -C {bash,zsh,powershell} | -l | -L LOGS [LOGS ...]] [-s SCRIPT]\n                [-a ARGS [ARGS ...]]\n                [ssh_args ...]\n\nssh-para v1.ssh-para.dev\n\npositional arguments:\n  ssh_args\n\noptions:\n  -h, --help            show this help message and exit\n  -V, --version         ssh-para version\n  -j JOB, --job JOB     Job name added subdir to dirlog\n  -d DIRLOG, --dirlog DIRLOG\n                        directory for ouput log files (default: ~/.ssh-para)\n  -m MAXDOTS, --maxdots MAXDOTS\n                        hostname domain displaylevel (default:1 => short hostname, -1 => fqdn)\n  -p PARALLEL, --parallel PARALLEL\n                        parallelism (default 4)\n  -t TIMEOUT, --timeout TIMEOUT\n                        timeout of each job\n  -r, --resolve         resolve fqdn in SSHP_DOMAINS\n  -v, --verbose         verbose display (fqdn + line for last output)\n  -D DELAY, --delay DELAY\n                        initial delay in seconds between ssh commands (default=0.3s)\n  -f HOSTSFILE, --hostsfile HOSTSFILE\n                        hosts list file\n  -H HOSTS [HOSTS ...], --hosts HOSTS [HOSTS ...]\n                        hosts list\n  -C {bash,zsh,powershell}, --completion {bash,zsh,powershell}\n                        autocompletion shell code to source\n  -l, --list            list ssh-para results/log directories\n  -L LOGS [LOGS ...], --logs LOGS [LOGS ...]\n                        get latest/current ssh-para run logs\n                        -L[<runid>/]*.out          : all hosts outputs\n                        -L[<runid>/]<host>.out     : command output of host\n                        -L[<runid>/]*.<status>     : command output of hosts <status>\n                        -L[<runid>/]*.status       : hosts lists with status\n                        -L[<runid>/]<status>.status: <status> hosts list\n                        -L[<runid>/]hosts.list     : list of hosts used to connect (resolved if -r)\n                        default <runid> is latest ssh-para run (use -j <job> -d <dir> to access logs if used for run)\n                        <status>: [success,failed,timeout,killed,aborted]\n  -s SCRIPT, --script SCRIPT\n                        script to execute\n  -a ARGS [ARGS ...], --args ARGS [ARGS ...]\n                        script arguments\n```    \nDuring run, use :\n* k: to kill ssh command held by a thread (but remote command can still be running on remote host)\n* p: pause all remaining jobs to be scheduled\n* r: resume scheduling of jobs\n* a: abort all remaining jobs\n* ctrl-c: stop all/exit (but remote commands launched by ssh can still be running on remote servers)\n\nEnvironment variables:\n* SSHP_OPTS: ssh default options (Eg: \"-F /home/user/.ssh/myconfig\")\n* SSHP_DOMAINS: dns domains to search when short hostname given (with -r/--resolve option)\n* SSHP_SYM_BEG: Symbol character for begin decorative (default: \"\\ue0b4\")\n* SSHP_SYM_END: Symbol character for end decorative (default: \"\\ue0b6\")\n* SSHP_SYM_PROG: Symbol character for progress bar fill (default: \"\\u25a0\")\n* SSHP_SYM_RES: Symbol character before ssh output line (default: \"\\u25b6\")\n\nActivate autocompletion:\n* `. <(ssh-para -C bash)`\n* `ssh-para -C powershell | Out-String | Invoke-Expression`\n\n# Example\n\nPatch redhat family hosts:\n```shell\nssh-para -p 20 -f hostlist.txt -- 'sudo yum update -y;sudo shutdown -r +1'\n```\nUse specific ssh options / config (everything after `--` will be passed to ssh command as is):\n```shell\nssh-para -p 20 -H host1 host2 -- -F ~/.ssh/myconfig echo connect ok\n```\nLaunch local script with argument on remote hosts:\n```shell\nssh-para -p 20 -f hosts.txt -s ./myscript -a status\n```\nExtend limited resolv.conf search domains (try to resolve host in each domain, first resolved in the domain list is used as fqdn):\n```shell\nSSHP_DOMAINS=\"domain1.com domain2.com\" ssh-para -r -H host1 host2 -- echo connect ok\n```\n\n# Tips\n\n* ssh-para uses ssh BatchMode, no interactive password/passphrase will be asked, so you need to have a ssh authorized key to connect to servers (ssh-agent...)\n* you need to configure your ssh for StrictHostKeyChecking/UserKnownHostsFile if you need to connect to unknown servers\n* to connect as different user use ssh -l option or define everything in your ssh config file\n  * *you can use user@host as hostname but not if you need to resolve host (-r/--resolve)*\n* 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\n  * *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>)*\n* 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.\n* Be very carefull when launching massive commands on servers... Always first test on non production.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 joknarf  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Interactive Parallel SSH jobs manager",
    "version": "1.4.5",
    "project_urls": {
        "Documentation": "https://github.com/joknarf/ssh-para/blob/main/README.md",
        "Homepage": "https://github.com/joknarf/ssh-para",
        "Repository": "https://github.com/joknarf/ssh-para.git"
    },
    "split_keywords": [
        "ssh",
        " cli",
        " parallel",
        " jobs"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "727ea6276ee3dfc430cc09202fa5728d69f6c9240d1bcc748b95487b774d5250",
                "md5": "806644e5ba8b1e5efb2a2d5d7862805f",
                "sha256": "0b7242cebfa687ab45ec49742be6c2cf92e3e76a9461988f850ce05cd19f1d63"
            },
            "downloads": -1,
            "filename": "ssh_para-1.4.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "806644e5ba8b1e5efb2a2d5d7862805f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 16111,
            "upload_time": "2024-09-14T09:06:50",
            "upload_time_iso_8601": "2024-09-14T09:06:50.470594Z",
            "url": "https://files.pythonhosted.org/packages/72/7e/a6276ee3dfc430cc09202fa5728d69f6c9240d1bcc748b95487b774d5250/ssh_para-1.4.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c946e323074a43965fa470776b13fe29a235da81d2bcb9e6b53f8a8671f66207",
                "md5": "d36cc59daf5f47184a8a0b18e70ab0c2",
                "sha256": "b2af95c0c051eea411a3a648887fa682f78d8010f33009fdade65c08baf092cc"
            },
            "downloads": -1,
            "filename": "ssh_para-1.4.5.tar.gz",
            "has_sig": false,
            "md5_digest": "d36cc59daf5f47184a8a0b18e70ab0c2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 20647,
            "upload_time": "2024-09-14T09:06:51",
            "upload_time_iso_8601": "2024-09-14T09:06:51.935144Z",
            "url": "https://files.pythonhosted.org/packages/c9/46/e323074a43965fa470776b13fe29a235da81d2bcb9e6b53f8a8671f66207/ssh_para-1.4.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-14 09:06:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "joknarf",
    "github_project": "ssh-para",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ssh-para"
}
        
Elapsed time: 0.42191s