paramiko
import paramiko import StringIO my_key = """\ -----BEGIN RSA PRIVATE KEY----- -----END RSA PRIVATE KEY-----""" pkey = paramiko.RSAKey.from_private_key(StringIO.StringIO(my_key)) ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(hostname='host', username='user', pkey=pkey) ... ssh.close()