How to use Pageant with Paramiko on Windows?

耗尽温柔 提交于 2019-12-06 04:38:56

问题


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.


回答1:


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()


来源:https://stackoverflow.com/questions/8490228/how-to-use-pageant-with-paramiko-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!