SSH Key-Forwarding using python paramiko

We are currently running a script on our desktop that uses paramiko for ssh for the remote linux host. When we are on a remote linux host, we execute another command to enter another remote machine. What we want to do is paramico pass the keys to the remote server so that we can reuse them for ssh on another remote host.

This will be the equivalent functionality of 'ssh -A remotehost.com' on linux.

+4
source share
1 answer

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

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.

+2
source

Source: https://habr.com/ru/post/1540608/


All Articles