0

I have 2 systems I work with that are daisy chained. System A is what I have to connect to initially, then I ssh into system B to run commands to view status of services and other things. I work doing field support on these systems and have no way to change the way they work in regards to creating APIs or how we connect to them.

What I want to do is have a ruby script that can get into system B to run some commands and then pass the output from those commands back into my laptop automatically.

I can use ruby gem net/ssh to get into system A and run commands but I cannot figure out how to ssh into system B after I am in system A. This is what I have right now.

    Net::SSH.start('123.456.78.9', 'username', password: 'password') do |ssh|
        # some how ssh into system b
    end

I tried just ssh.exec! "ssh 123.456.78.30" but that does not work. I tried nesting another Net::SSH.start call but that doesn't work either.

Finally, I'd also like to scp files from system B back to a /tmp folder in system A but I can't get that to work either. That's a whole other thing but if anyone has any advice on that I would appreciate it.

Also just a note that the password I put in the script isn't the actual password. When ruby net/ssh runs and it hits the wrong password the shell prompts for a password and I put the actual one in. Maybe I can do that a less hacky way but right now it's not the priority.

Nick D
  • 115
  • 8
  • Are you able to SSH from terminal? SCP? – Azeem Sep 15 '18 at 06:17
  • @Azeem Yes I ssh all the time using terminal through A into B, but I can't figure out the right syntax or gem to use to get into B using the ruby script. I can also scp files from B to A and then A to my laptop. – Nick D Sep 15 '18 at 10:32

0 Answers0