skip to navigation
skip to content

Not Logged In

parallel-ssh 0.3

Wrapper library over paramiko to allow remote execution of tasks. Supports parallel execution on multiple hosts

Latest Version: 0.70.2

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.

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
 
File Type Py Version Uploaded on Size
parallel-ssh-0.3.tar.gz (md5) Source 2014-03-10 3KB
  • Downloads (All Versions):
  • 31 downloads in the last day
  • 308 downloads in the last week
  • 964 downloads in the last month