import paramiko
import select
client = paramiko.SSHClient()
client.load_system_host_keys()
client.connect('host.example.com')
transport = client.get_transport()
channel = transport.open_session()
channel.exec_command(COMMAND)
while True:
    rl, wl, xl = select.select([channel], [], [], 0.0)
if len(rl) > 0:
    pass
Executing a long running command through paramiko