如何在 Windows 上将 Pageant 与 Paramiko 一起使用? [英] How to use Pageant with Paramiko on Windows?

查看:53
本文介绍了如何在 Windows 上将 Pageant 与 Paramiko 一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 Paramiko 在 Windows 下支持 Pageant,但它默认不工作.

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

我正在寻找使用在 Pageant 中加载的密钥进行连接的示例.

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

推荐答案

这是我使用 Pageant 连接和执行自动登录以存储我的密钥,并从我的 Python 脚本中连接到它的方法.它依赖于已经加载的 Pageant,(我还没有找到一种可靠的方法来启动它并加载密钥(提示输入密钥密码)),但下面的方法现在有效.

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

这篇关于如何在 Windows 上将 Pageant 与 Paramiko 一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆