SSH Key-Forwarding using python paramiko
Asked Answered
A

1

7

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.

Adabelle answered 14/5, 2014 at 23:3 Comment(0)
C
7

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.

Curly answered 16/9, 2016 at 1:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.