This is what I use to connect and automatically log in using Pageant to store my key and connect to it from my Python script. It expects to load Pageant (and I did not find a reliable way to start it and download the key (hint for the key password)), but it works lower now.
ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) host = 'somehost.com' port = 22 ssh.connect(host, port=port, username='user', allow_agent=True) stdin,stdout,stderr = ssh.exec_command("ps -ef") print stdout.read() print stderr.read()
source share