Wrapper library over paramiko to allow remote execution of tasks. Supports parallel execution on multiple hosts
Project description
Small wrapper library over paramiko that allows for parallel execution of SSH commands on remote hosts and executing simple single host commands over SSH.
parallel-ssh uses asychronous network requests - there is no multi-threading or multi-processing used.
This is a requirement for commands on many (hundreds/thousands/hundreds of thousands) of hosts which would grind a system to a halt simply by having so many processes/threads all wanting to execute if done with multi-threading/processing.
Module documentation can be found at read the docs.
Installation
$ pip install parallel-ssh
Usage Examples
See documentation on read the docs for more complete examples
Run ls on two remote hosts in parallel.
>>> from pssh import ParallelSSHClient >>> hosts = ['myhost1', 'myhost2'] >>> client = ParallelSSHClient(hosts) >>> cmds = client.exec_command('ls -ltrh /tmp/aasdfasdf', sudo = True) >>> print [client.get_stdout(cmd) for cmd in cmds] [localhost] drwxr-xr-x 6 xxx xxx 4.0K Jan 1 00:00 xxx [{'localhost': {'exit_code': 0}}]
SFTP support
SFTP is supported (scp version 2 protocol) natively, no scp command used.
For example to copy a local file to remote hosts in parallel
>>> from pssh import ParallelSSHClient >>> hosts = ['myhost1', 'myhost2'] >>> client = ParallelSSHClient(hosts) >>> client.copy_file('../test', 'test_dir/test') >>> client.pool.join() Copied local file ../test to remote destination myhost1:test_dir/test Copied local file ../test to remote destination myhost2:test_dir/test
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file parallel-ssh-0.61.tar.gz
.
File metadata
- Download URL: parallel-ssh-0.61.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d856f3ffe6e5b99cdb84011393341b770812a4e8edcd780c6c33899f5a65468 |
|
MD5 | bdd1944fa804f8d70fc72562b460f69f |
|
BLAKE2b-256 | 5ee944ee25a454a1faed92537ff579055030fc82a5ddc786c04231aee2f5453f |