From Wiki

Jump to: navigation, search

As a companion to ReverseSshTunnels, its also useful to know how to do "forward" ssh tunnels, or simply "port forwarding".

let's say you are at a machine called "work", and you want to connect to a vnc session on a machine named "home".

first, from work, run this:

ssh -L 9999:localhost:5901 home

now run your vncviewer:

vncviewer localhost:9999

now let's say that "home" is actually behind a NAT router, and that ssh on "home" is exposed to the internet via a port forward on the NAT router, such that port 2222 on the NAT router is forwarded to port 22 on "home". in this case, you'd run:

ssh -L 9999:localhost:5901 -p 2222 home
Personal tools