使用python paramiko进行SSH密钥转发 [英] SSH Key-Forwarding using python paramiko

查看:457
本文介绍了使用python paramiko进行SSH密钥转发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们当前在桌面上运行一个脚本,该脚本使用paramiko SSH到远程Linux主机.在远程Linux主机上后,我们将执行另一个命令以登录另一台远程计算机.我们想要做的是从paramiko将密钥传递到远程服务器,以便我们可以再次使用它们将ssh传递到另一台远程主机.

We currently run a script on our desktop that uses paramiko to ssh to a remote linux host. Once we are on the remote linux host we execute another command to log into another remote machine. What we want to do is from paramiko pass the keys to the remote server so we can use them again to ssh to another remote host.

这将是Linux中'ssh -A remotehost.com'的等效功能.

This would be the equivalent functionality of 'ssh -A remotehost.com' in linux.

推荐答案

您可以使用

You can enable SSH agent forwarding for a session in paramiko using AgentRequestHandler. To do this, call paramiko.agent.AgentRequestHandler(s) with the session s. For example:

client = paramiko.client.SSHClient()
client.connect(host, port, username)
s = client.get_transport().open_session()
paramiko.agent.AgentRequestHandler(s)

有关更多详细信息和代码,请参见这篇文章.

See this post for more details and code.

这篇关于使用python paramiko进行SSH密钥转发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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