How do I set up an SSH tunnel to a whitelisted box?

3

1

We have a trusted machine which is authorized to connect to a special web service on port 12345, as shown below. The web service whitelists specific clients, and only those IP addresses are allowed to connect.

[ restricted-access ]       [ trusted machine ]
[    web service    ] <===> [                 ]
[ example.com:12345 ]       [   mycorp.com    ]

My machine is authorized to connect to the trusted machine:

[ restricted-access ]       [ trusted machine ]           [    my box   ]
[    web service    ] <===> [                 ] <--ssh--> [             ]
[ example.com:12345 ]       [   mycorp.com    ]           [ workbox.com ]

I have a script foo.rb which tries to connect to example.com:12345. It fails, since I'm not authorized to connect to example.com directly. Only the trusted box at mycorp.com can do this.

How do I set up an SSH tunnel so that the script can successfully make the connection?

Dave Riseman

Posted 2010-10-08T14:06:09.607

Reputation: 71

What will you be using to connect? Putty? Or SSH on a terminal? – Nick – 2010-10-08T17:24:31.013

Answers

4

Figured it out. I used:

ssh -f -N -L 12345:example.com:12345 me@mycorp.com

I then edited my hosts file so that example.com requests to go the mycorp.com proxy. Crude but effective.

Dave Riseman

Posted 2010-10-08T14:06:09.607

Reputation: 71