1

I can connect to postgres server as below

self.ssh = paramiko.SSHClient()
self.ssh.load_system_host_keys()
self.ssh.connect('hostname', username='uname')

But I have to connect to another server after I connect to first one. So in terminal

  • first: ssh uname@hostname
  • second: ssh uname2@hostname@ (in server 1)

How do I this in python code? I tried

self.ssh = paramiko.SSHClient()
self.ssh.load_system_host_keys()
self.ssh.connect('hostname', username='uname')
self.ssh.connect('hostname2', username='uname2')

But this doesn't work

I tried to use transport but couldn't get concept clear

Erik Kaplun
  • 37,128
  • 15
  • 99
  • 111
user2661518
  • 2,677
  • 9
  • 42
  • 79
  • @MartinPrikryl so looking at the link I see transport = paramiko.Transport((hostname) then do connect for first hostname and then forward tunnel to second hostname? Do I need to do connect for second hostname again? And I also couldn't import forward library.. – user2661518 Oct 06 '15 at 17:24

0 Answers0