from subprocess import Popen, PIPE
stdout, stderr = Popen(['ssh', 'user@remote_computer', 'ps -ef'], stdout=PIPE
    ).communicate()
print(stdout)
how to get console output from a remote computer (ssh + python)