Site menu:

Sponsored by

Bitcube Ltd.  Expert Linux Consultancy

Categories

Meta

Site search

 

July 2009
M T W T F S S
« Jun   Aug »
 12345
6789101112
13141516171819
20212223242526
2728293031  

Archives

Links:

Remote desktop on Linux

As all geeks know, we have to help others less geeky with their computers.

As a Linux geek, this means helping out my parents with their Ubuntu PC. So how do I do this:

First step is to tweak their ADSL router to allow me access via ssh. This is very router specific but you want to “port forward” port 22 to the PC in question. I suggest you harden this in two ways – firstly don’t use port 22 on the outside – use a different one such as 9876 (but still forward it to port 22 on the destination). Secondly install fail2ban or denyhosts to block bruteforce attacks that still find it.

Now check that this works:
* ssh -L 5900:localhost:5900 youruser@remotepc [-p 9876]

Alternatively in ~/.ssh/config:

Host remotepc
user youruser
port 9876
LocalForward 5900 localhost:5900

We now need to run x11vnc as the user who is logged in (i.e. “otheruser” in my case):
* sudo -u otheruser x11vnc -ncache 10 -many -solid darkgreen -auth ~otheruser/.Xauthority -display :0
** -ncache 10 should speed things up (but uses memory)
** -many means that you can reconnect
** -solid darkgreen replaces any desktop background, making it faster
** -auth ~dad/.Xauthority is required to gain access to the display (can be omitted if you login as the correct user)
** -display :0 is the local display (normally! often if you login via SSH it will be set back to _your_ PC otherwise)

Back on your PC run this:
* xvncviewer -PreferredEncoding ZRLE :0
** the preferredencoding is required as otherwise vnc believes that it is running locally and that there is oodles of bandwidth
** add -lowcolourlevel 2 if you want it prettier (note the English spelling)
** add -FullColour if you _really_ want it

That’s it.

Comments

Comment from Dave Walker
Time: Sunday 26 July, 2009, 17:50

Hi Adrian,

Nice write up.. Rather than setting up the ssh tunnel first, i tend to:
xvncviewer -via “name@ipaddress -p9876″ localhost:0

This will create, and tear down the tunnel so it’s only up whilst you are viewing.

Write a comment