简体   繁体   中英

SSH Key-Forwarding using python paramiko

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM