0

I would like to know how to to jump from one remote server to another remote server using paramiko. I want to ssh from my local pc to remote-A then from remote-A to remote-B and from remote- B to remote-C.

import paramiko
def connect(ip, usr, psw):
 client = paramiko.SSHClient()
 client.load_host_keys('/home/dgomez/.ssh/known_hosts')
 client.connect(ip, username=usr, password=psw)
 return client

host1 = connect('192.168.1.2', 'username', 'password')
# Here I'm connect to remote-A

Now I would to know how can I connect from Remote-A to Remote-B.

amb1s1
  • 1,995
  • 5
  • 22
  • 26
  • You might want to check this out. http://stackoverflow.com/questions/1911690/nested-ssh-session-with-paramiko – dusual Apr 04 '13 at 18:02
  • This is possibly a duplicate of the question mentioned above. Also you should really check your architecture or how you server management if you have to do something like this – dusual Apr 04 '13 at 18:06

1 Answers1

1

use for pexpect module it is very useful for you http://www.noah.org/wiki/pexpect and and pexpect module simplified in pxssh module that very good for remote login http://dsnra.jpl.nasa.gov/software/Python/site-packages/Contrib/pxssh.html simple code:

import pxssh
host = pxssh.pxssh
host.login('hostname','username','password')
host.sendline('command')#'ls'
print host.before
Reegan Miranda
  • 2,879
  • 6
  • 43
  • 55