Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Pageant with Paramiko on Windows?

I know that Paramiko supports Pageant under Windows, but it doesn't work by default.

I am looking for an example of connecting using the key that is loaded in Pageant.

like image 917
sorin Avatar asked Dec 13 '11 13:12

sorin


People also ask

What is Windows Pageant?

Pageant is an SSH authentication agent. It holds your private keys in memory, already decoded, so that you can use them often without needing to type a passphrase.1.

What is Pageant in PuTTY?

Pageant is a PuTTY authentication agent. It holds your private keys in memory so that you can use them whenever you are connecting to a server. It eliminates the need to: Explicitly specify the relevant key to each Linux user account, if you use more than one account to log into a server.

What is Paramiko transport?

class paramiko.Transport. An SSH Transport attaches to a stream (usually a socket), negotiates an encrypted session, authenticates, and then creates stream tunnels, called Channels, across the session. class paramiko.SSHClient. A high-level representation of a session with an SSH server.

Is Paramiko open source?

Open Source Python-paramiko is used by IBM Netezza Host Management.


1 Answers

This is what I am using to connect and do an automated login using Pageant to store my key, and connecting to it from within my Python script. It counts on Pageant already being loaded, (and I haven't found a good reliable way to launch it and load the key (prompt for key password)) but the below works for 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()
like image 164
captainawol Avatar answered Oct 07 '22 03:10

captainawol