Skip to main content

Transfer a local script file to a remote host and execute it.

Project description

Remote Runner

Transfer a local script file to a remote host and execute it.


  • Python 2.7 and Python 3 are supported.

  • Paramiko 1.10+.


pip install remrunner


from remrunner import runner
r = runner.Runner(host, username)

rval, stdout, stderr ='/path/to/local/')
if rval:



  • Great when using scripts to collect information from a large number of remote hosts.

  • No need to maintain scripts across multiple systems. Only the script versions on the local host need to be maintained.


Named files are copied to a temp location (./.remrunner/[PID]/) on the remote host, permissions are set to 0700, and script is then executed.

On cleanup, the [PID] directory and all contents are removed before closing the connections.


Class Runner

init(host, user, kwargs)

host : Required. IP Address or FQDN

user : Optional. Defaults to current running user on local machine.

keyword-args: auto_add : (Boolean) Defaults to True. Set Paramiko Client.AutoAddPolicy.

run(script, sudo, timeout, opts)

Run the named local script on remote host.

script : Path to script on local machine

sudo : (Boolean) Defaults to False. When true, the execution command on remote machine will be prefaced with “sudo “

timeout : (seconds, optional) Defaults to 10

opts : optional command-line arguments that will be passed to remote script.


Clean up temporary directories on remote host and close SSH and SFTP sessions.


  • Run remote script with sudo:, True)
  • Run remote script and specify a 60 second timeout:, False, 60)
  • Run remote script with timeout and optional arguments:, False, 15, "--verbose --interval=4")

Known Issues

Currently, as this is intended to be used for automation, remrunner assumes that SSH keys to allow password-less logins are already in place. There is no option to prompt for password or ssh passphrase. Maybe in a future release.

To Do

Could use better exception handling in a few places. Needs a tests. Probably needs sanitizing/de-tainting of optional user arguments.


Jeff Leary (sillymonkeysoftware -at- gmail -dot- com)

Project details

Download files

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

Source Distribution

remrunner-0.5.tar.gz (3.9 kB view hashes)

Uploaded Source

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