Saturday, November 5, 2011

Configure X11VNC in Ubuntu 11.10 a.k.a Oneiric Ocelot

As you should know the new Ubuntu version is out almost one month already but I just got time to play with it. The upgrade  process as usual was easy. It took some hours but it was smooth. The first thing I did was to remove Ubuntu Unity. I might write an entire post about it but right now I am just going to say that I hate it!

When everything finished I noticed I could not remote desktop it using VNC as I always do then the problems started. Searching  in Google I found that this is a known issue in this version and a lot of users keep complaining about it ( myself among them ).

Looking for another options to access my server remotely I found that X11VNC was my best option. The best thing about it is its great options it has for command line control and the best thing is that even if there is no user log in into the terminal you can still start the server, this was a huge limitation about Vino-VNC (the default VNC server Ubuntu ships). First a user has to log in so the server could start, there was no way to start it from command line or ssh. It demands to have a monitor attached.

Anyways after the usual "sudo-apt install X1vnc" to install the required x11vnc packages these are the commands you need to run in order to make it work:

if there is user a user already logged in:
x11vnc -display :0
if nobody is logged in:
sudo x11vnc -auth /var/run/lightdm/root/:0 - display :0
If you notice, you will need to run it as super user since that path needs super user privileges.

The -auth parameter needs the path to the display manger if no one is logged into, but there is a greeter login program like gdm ( Ubuntu ), kdm ( Kubuntu ), xdm ( Xubuntu) , etc running so it might vary on different platforms. You can try 2 things:

This will try to guess the path
x11vnc -auth guess -display :0
Sometimes executing:
ps wwwaux | grep auth
can show you the path to that file, in my case it did.

This tool has tons of options but one I really found  useful is the geometry option, which lets scale the screen to fit your needs or if you are connecting from slow internet bandwidth :
x11vnc -display :0 -geometry 1024x764
Once the server is up and running you should something like this:
The VNC desktop is [YOUR SERVER NAME]:0

And you are all set and ready to connect using your favorite client.

Connecting to the login screen

You can find all the documentation and all the options you can use in this page and here

Hopes it helps while we wait for the bug to be fixed.

Happy coding :)