0

I have several computers running several virtual machines on bridged connections. I want to create a script that ultimately allows me to SSH into any computer, change some files, and then SSH into another VM or computer from that computer.

How can I use Paramiko to SSH from computer A to computer B, and then from computer B to computer C (without exiting the connection from A first)? Does this change at all when dealing with virtual machines on the same LAN using bridged connections?

AlwaysQuestioning
  • 1,464
  • 4
  • 24
  • 48

1 Answers1

1

I've used Paramiko to do this a few times before, it's been a little while and I don't have those old scripts at hand for reference, but take a look at this same question on SO:

Nested SSH session with Paramiko

I used pexpect however, and it's probably a better way of doing it at first glance.

If I get a chance tomorrow I might be able to find the scripts I wrote and post some sample code.

Community
  • 1
  • 1
Richard Dunn
  • 6,165
  • 1
  • 25
  • 36
  • Thank you. I'll take a look at pexpect now. I saw that old post and didn't find it particularly useful. This is a long-term project I'm working on, so if you find the scripts tomorrow I'll certainly be checking. – AlwaysQuestioning Oct 10 '15 at 18:49
  • Yeah, the stuff in that post ain't pretty tbh. I'll give it a look tomorrow and see if I can find it, I wrote it at an old job and might not have taken it with me, but I did definitely save some paramiko stuff so I might be able to remember the jist of it. – Richard Dunn Oct 10 '15 at 18:55
  • 1
    I can't see the old scripts I had, soz. If I have time this week I'll write something up as an example; I'll definitely need to use it again in the near future anyway, so I'm happy to go over it. I can't promise I'll have time though... – Richard Dunn Oct 12 '15 at 12:51
  • Not a problem -- I'll be checking regardless! Thanks. – AlwaysQuestioning Oct 12 '15 at 15:54