我知道Paramiko在Windows下支持Pageant,但它在默认情况下不起作用。
我正在寻找一个使用Pageant中加载的密钥进行连接的示例。
发布于 2012-02-07 00:40:32
这是我用来连接并使用Pageant自动登录来存储我的密钥,并从我的Python脚本中连接到它的方法。它依赖于已经加载的Pageant (我还没有找到一个可靠的好方法来启动它并加载密钥(提示输入密钥密码)),但现在可以使用下面的方法。
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
复制相似问题