Sunday, September 11, 2011

SSH Tunneling


You have a trouble when you got your localhost (your computer) has no route to XWindows public server (linux, unix base). Your computer only has route to one of computer in the network which has route to public server that you want.
Somebody that ever install Oracle via remote connection will find this problem.
Example:
Your local computer is “localhost”
Your server #1 is private IP “192.168.12.15″
Your server #2 is public IP “202.153.99.9X”

Localhost —– Server #1 ——- Server #2
|______ XWindows Application _______|
|___________ No Route ______________|

How to get connection via SSH so you can remote your public server include the XWindows application ?
Here are the steps must be done :
SSH tunneling from 192.168.12.15 to public IP 202.153.99.9X
ssh root@192.168.12.15 -p 2350
ssh -L 2211:127.0.0.1:2350 root@202.153.99.9X -p 2350
SSH tunneling from localhost to 192.168.12.15
ssh -L 2211:127.0.0.1:2211 root@192.168.12.15 -p 2350
SSH to 202.153.99.9X via tunnel + forward X
ssh -X root@localhost -p 2211
For example on X environment :
xclock &
You will get “xclock” program from remote 202.153.99.9X