加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

如何在Windows上使用Paramiko的Pageant?

发布时间:2020-12-14 04:31:11 所属栏目:Windows 来源:网络整理
导读:我知道Paramiko在 Windows下支持Pageant,但默认情况下不起作用. 我正在寻找使用Pageant中加载的密钥进行连接的示例. 解决方法 这就是我用来连接并使用Pageant进行自动登录来存储我的密钥,并从我的 Python脚本中连接到它.它依赖于Pageant已经被加载,(并且我没
我知道Paramiko在 Windows下支持Pageant,但默认情况下不起作用.

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

解决方法

这就是我用来连接并使用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()

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读