Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have three boxes. Box 1 can ssh to Box 2 and Box 3. I want to be able to ssh from Box 2 to Box 3 via Box 1. How can I do this?

I tried this (but this doesn't work).

 on Box 1: ssh -t -R 9999:localhost:22 -N Box_2
 on Box 1: ssh -t -L 9999:localhost:9999 -N Box_3

So, that I can do this on Box 2:

 ssh localhost -p 9999

which will connect me directly to Box 3.

share|improve this question

2 Answers 2

I think what you want to do is to arrange for ssh from box 2 to proxy through box 1, optionally using a ControlMaster connection so that everything is multiplexed over the same connection. This article describes one way to set it up.

share|improve this answer
    
I looked at the article that you posted but the article describes a situation like: Box 1 > Box 2 > Box 3 where you can jump to Box 3 from Box 1. What I want is something like this: Box 2 < Box 1 > Box 3 . So that I can jump from Box 2 to Box 3 immediately. –  Carmen Mar 31 '11 at 22:51
    
That should just change where you do each step of it, not how you do it. –  geekosaur Mar 31 '11 at 22:53

Here is how you can setup the tunnels

box 1: ssh -R 9999:box3:22 box2

box 2: ssh -p 9999 localhost

The last command will take you to port 22 on box3 through box1. The way you had it you ended up with port 9999 on box1 going to port 22 on box2.

Ironically, I'm writing this as my daughter watches the spongebob episode that is about playing in a box.

share|improve this answer
    
No, because box 1 can ssh to box 2 and can ssh to box 3. box 2 and box 3 cannot ssh to each other. The only way to connect box 2 and box 3 is via box 1. –  Carmen Mar 31 '11 at 23:10
    
Ok, sorry I misunderstood. Usually people use box1 and box2 to mean go to box3 through box2. I see, you're initiating the tunnel from the network you want to go to so that you can get back into it. I'll change my example to work for you. –  deltaray Mar 31 '11 at 23:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.