ssh_tunnel

SSH Tunnelling (Port Forwarding)

<work>:
The machine's IP which you want to connect to but sit behind <gate>.
<gate>:
The machine's IP which you can directly access.

This command will let you to access <work> machine directly by connecting to localhost's port 7777. Open an ssh connection as user myuserid to host gate and execute the command cat -. While the session is open, redirect all connections to port 7777 on the local machine to port 22 on machine work.

If you need to access more remote machine port, just add -L option!

$ ssh  -l myuserid  -L 7777:<work>:22  [-L <port>:<other work>:<other work's port>] <gate>  cat -

SSH (Port Forwarding)

When you have two machines A and B. And you want to pass all traffic from A:port1 to B:port2.
For example, for remote desktop to B and only A can access B.

$ ssh -N -f -L [<A's ip>:]port1:'address of B':'port2 localhost

Reference

http://www.rzg.mpg.de/networkservices/ssh-tunnelling-port-forwarding

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License