Friday, 24 July 2009

SSH TUNNELLING

ssh -f <user>@<ssh-server-address> -p <ssh-port> -L <source-port>:<destination-address>:<destination-port> -N

So say you wanted to vnc though an ssh tunnel you could use this command:
ssh -f user@my-ssh-server -p 2299 -L 5910:my-vnc-server:5900 -N

Then in your vnc client you would connect to:
localhost:5910

So what's happening here?
First you're logging in via ssh to my-ssh-server on port 2299 (ssh -f user@my-ssh-server -p 2299), you don't need to specify the port unless it is different from the default (22).

The -f tells ssh to run in the background.

Then you're telling any traffic on port 5910 to forward to my-vnc-server on port 5900 (-L 5910:my-vnc-server:5900).

The -N instructs OpenSSH to not execute commands on the remote system.

0 comments: