Using VNC is an effective way for remotely connecting to a box running Ubuntu 13.04. The good news is that it can be done. The bad news is that with every release of the Gnome / Unity it gets trickier for setting it up. Here are the steps to do that.
The basic requirement for running the VNC server on a Ubuntu box is to have the server itself installed.
$ sudo apt-get install vnc4server
Now we start the VNC server for the first time:
The console program will prompt for the password (which needs to be between 6 and 8 characters long - being security-conscious I would not want to use this service on an open network) and a confirmation of the password. When we are done it will start a server at the display
:1 (or the next available one as indicated in the console output).
We can now connect to the VNC server using a VNC client. The port number to be used starts at 5900, then we need to add to it the display number of the VNC server. This means that in the default case your VNC client needs to connect to
In our VNC client's window we will see that the VNC server has started a very basic windows server, a control panel with a few checkboxes and a terminal window. If this is all we wanted, then we are done. But to use the VNC to connect to the gnome desktop, we need to do further steps.
The window manager and desktop used depends on the contents of the start-up script in the
~/.vnc/xstartup. By default, the following line starts up the basic x-windows manager:
In the past (say, in Ubuntu 12.04), this would be replaced by:
# this does not work in 13.04 gnome-session &
and a result would be a nicely working Unity environment in the VNC. In 13.04 this no longer works. Instead, we need to use the following line:
# the Ubuntu 13.04 way gnome-session-fallback &
This environment is not installed by default, so after we save and close the
xstartup script, we need to install it:
$ sudo apt-get install gnome-session-fallback
Now stop the previous VNC server session and start a new one:
$ vncserver -kill :1 $ vncserver
(Yes, that's a single-dash
-kill. Using anything else will just start a new VNC server.)
If in your VNC window you will see the following message: Could not acquire name on session bus or the screen remains grey with no Gnome elements, then add the following line at the top of the
xcode script near the other
$ unset $ DBUS_SESSION_BUS_ADDRESS
~/.vnc/xcode script looks like this:
#!/bin/sh # Uncomment the following two lines for normal desktop: #unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS # exec /etc/X11/xinit/xinitrc [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic & \ x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & \ gnome-session-fallback &
If this is a fresh install of the whole environment, then everything shoulw work. You will find that the desktop is now back to the old Gnome look and feel rather than the one of the Unity. The price of the progress?
However, I have been upgrading from the old environment, and I soon encountered another problem: pressing
d anywhere would act as the "show desktop" shortcut, minimising all the windows. I was not alone with the problem, and this post (and the post linked within) helped me with a work-around.