Tuesday, December 30, 2014

Enabling VNC in Ubuntu 14.04 (Trusty Tahr)

I had the interesting request to configure VNC for a user running Ubuntu 14.04 today, although with slightly different requirements than normal. The user wanted to connect via VNC, and go straight to the Ubuntu Unity desktop. At first glance this seems easy, but then I wouldn't be writing this.

From everything I found, the Unity desktop is not designed to work well with VNC. Googling "ubuntu vnc desktop" returned multiple pages of people configuring their systems with vnc4server or tightvnc, but then configuring the system to load gnome or some other desktop. Never did anyone successfully get VNC working with the unity desktop.

A bit more searching and I found a reference to Ubuntu Desktop Sharing. It appears that Ubuntu comes with a built-in VNC server named vino. By opening the search tool and typing in Desktop Sharing or Vino, you can configure the sharing preferences. Enable Allow other users to view your desktop, Allow other users to control your desktop, Require the user to enter this password, and enter a password.
When the settings are saved, there is one more option to set. Open a terminal window and type the following:
gsettings set org.gnome.Vino require-encryption false
This configures the necessary encryption settings to allow a remote client to access the VNC server.

Using a VNC Viewer on another system, such as the one from RealVNC, connect to the system by IP or name. When prompted, enter the password, and you will be presented with your desktop.

Only 1 problem remains at this point - if the user logs off or reboots, the VNC server goes away with it. Once gone, you have to log into the GUI manually, and then the VNC server is started again. In my instance, I am working with only 1 user on this system, so I am able to use auto-login.

Again, open the search tool and type in Login. This pops up the user configuration tool, where you can select your user and enable auto-login.
Once completed, reboot the system and watch it automatically login your user. And because the user is configured for Desktop Sharing, the VNC server starts automatically, thereby sharing out the desktop.


Gareth Howell said...

I've been trying to follow your recipe to access an Ubuntu desktop system that's a KVM zone on a SmartOS server, but it's not working. I can't connect from Chicken. I get a "unknown auth type 18" error.

I turned off encryption, but it appears this doesn't stick across a reboot. Any ideas?


Brad Stuart said...

Hey, been searching for ages to get this to work. cheers!