我知道Paramiko在Windows下支持Pageant,但默认情况下它不起作用。
我正在寻找使用 Pageant 中加载的密钥进行连接的示例。
这就是我用来连接和自动登录的方法,使用 Pageant 来存储我的密钥,并从我的 Python 脚本中连接到它。它依赖于已经加载的选美,(我还没有找到一个好的可靠的方法来启动它并加载密钥(提示输入密钥密码)),但下面的方法目前有效。
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()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)