Wednesday, June 27, 2007

SSH Tunneling Tested With VNC

In order to connect to a VNC server (or any other server) via ssh, first you need to create an ssh tunel. A tunel specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side (with -R you have the inverse, remote port forwarded to local).

You can create a tunel by tiping the folowing command:


# ssh -L local_port:127.0.0.1:remote_port you_login_on_remote_host@remote_host_ip


now you will have to input your ssh password, wich is your password on the remote host.
With this tunel when you connect a VNC client (or any other client) to your "local_port"
on the localhost (127.0.0.1) the data the client generated is sent through the tunel
to the "remote_port" on the remote host which is the VNC server port (or any other server).

To connect your VNC client through the tunel (assuming you use vncviewer), type the folowing comand:


# vncviewer 127.0.0.1:local_port


now input the vnc password, and that's it, you sould see a window with the remote desktop.

Note: the data in the tunel on the network is encripted, so an ssh tunel provides you security on the network, you can have a tunel that goes through the internet and no one will see what you are transfering, because all of the data is encripted.

No comments: