Run python code via ssh with a decorator

decorator, jupyter, ssh, jupyter-notebook, server
pip install ssh-decorate==0.1


SSH Decorator

Important note !

It has been brought to our attention, that previous versions of this module had been hijacked and uploaded to PyPi unlawfully. Make sure you look at the code of this package (or any other package that asks for your credentials) prior to using it.

Basic Usage

Install with

pip3 install git+git://

Running code on a remote server is as simple as

from ssh_decorator import ssh_connect
ssh = ssh_connect('server', 'user','password')

# Run a python function
def python_pwd():
    import os
    return os.getcwd()

print (python_pwd())

# Run a bash command
ssh >> "ls"

Custom private key path or port ? no problem !

ssh = ssh_connect('server', 'user','password',
      privateKeyFile = "path/to/key", port=22)

Manual code execution

# Remote shell/bash command

# Remote python command
ssh.exec_code("print ('hello world')")

File Transfer

# Download
ssh.get_file("", "")

# Upload
ssh.put_file("", "")    

Running on a pool of servers

from ssh_decorator import ssh_pool
pool = ssh_pool([
   {"server": "server1", "user": "user1", "password": "pass1"},
   {"server": "server2", "user": "user2", "password": "", "privateKeyFile": "~/.ssh/id_rsa"},

def pool_ls():
   import os
   return os.listdir(".")

print (pool_ls())