Linux Blog

Use VNC through SSH

Filed under: Quick Linux Tutorials — TheLinuxBlog.com at 11:33 am on Thursday, November 20, 2008

Here is another quick tutorial;

Some times its nice to tunnel through SSH. Perhaps you have SSH running but the firewall does not allow anything but SSH in. You can tunnel VNC (or any other service) through SSH by doing the following:

On the machine local to you establish an SSH connection to the remote machine with “Local (-L)”  port forwarding. This may seem confusing and often confuses me, where [-p PORT] is optional

 ssh -L 5901:localhost:5900 username@HOST [-p PORT];

Once I have the connection established I can now use vncviewer to connect to my local host with the port specified

vncviewer  localhost:5901

Thats all there is to it, have fun!


4 Comments »

Pingback by links for 2008-11-22 « B-link List

November 22, 2008 @ 8:02 pm

[…] The Linux Blog » Use VNC through SSH Some times its nice to tunnel through SSH. Perhaps you have SSH running but the firewall does not allow anything but SSH in. You can tunnel VNC (or any other service) through SSH by doing the following (tags: vnc ssh tunnel linux) […]

Comment by Luis

December 11, 2008 @ 4:59 pm

you can also do

ssh -X user@host vncviwer localhost:0

Comment by Luis

December 11, 2008 @ 4:59 pm

or use FreeNX; it also is a good tool for remote desktop functionality that is free.

Comment by Ben Browning

December 13, 2008 @ 11:15 am

You can also do this in your ~/.ssh/config, like:

Host some.host.name
LocalForward 5901 192.168.42.10:5901
User yourusername

That way it works automagically.

Of course, my config block for my home machine also enables a funny SSH port and X11 forwarding… :)

~Ben

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>