What is the simplest way to SSH using Python?

linux, python, ssh, unix

Solution

I haven't tried it, but this pysftp module might help, which in turn uses paramiko. I believe everything is client-side.

The interesting command is probably `.execute()` which executes an arbitrary command on the remote machine. (The module also features `.get()` and `.put` methods which allude more to its FTP character).

UPDATE:

I've re-written the answer after the blog post I originally linked to is not available anymore. Some of the comments that refer to the old version of this answer will now look weird.

Problem

How can I simply SSH to a remote server from a local Python (3.0) script, supply a login/password, execute a command and print the output to the Python console? I would rather not use any large external library or install anything on the remote server.

Original source