Skip to main content

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) 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.

https://api.travis-ci.org/pkittenis/parallel-ssh.png?branch=master

Installation

To install gevent you need the libevent-dev package installed. Instructions below are for apt-get systems, substitute with your own package manager if necessary.

$ sudo apt-get install libevent-dev
$ pip install parallel-ssh

Usage Example

>>> 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

This version

0.3

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

parallel-ssh-0.3.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file parallel-ssh-0.3.tar.gz.

File metadata

  • Download URL: parallel-ssh-0.3.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for parallel-ssh-0.3.tar.gz
Algorithm Hash digest
SHA256 3415929920a59f96e133d8e10be69ceff90ff5771a22b84c7320c6f0d6e3e3d1
MD5 5d8019f26580f348377cae707555badb
BLAKE2b-256 ef3b31f3795cec8967e2f3da3a3ff1af4330243461e940afc993939d3535bd8d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page