Configuring VNC on Ubuntu Server

I recently configured VNC on my home server. This enables me to log on to the server and work in a GUI environment. I am using GNOME basic.

Server – Assumed Ubuntu Server 14.04

Pre-reqs – Install GNOME basic desktop

sudo apt-get install --no-install-recommends ubuntu-desktop

Install gnome-panel

sudo apt-get install gnome-panel

Install VNC Server. I used TightVNC Server

sudo apt-get install tightvncserver

Set up VNC initial configuration

vncserver

Stop the VNC session

vncserver -kill :1

Backup  existing xstartup file

mv ~/.vnc/xstartup ~/.vnc/xstartup.old

Create new xstartup file

vi ~/.vnc/xstartup

Add following

#!/bin/sh
export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
/etc/X11/Xsession
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
gnome-terminal &

Grant executable permissions to the xstartup file

chmod +x ~/.vnc/xstartup

Create  VNC Service file

sudo vi /etc/init.d/vncserver

Add following (replace user with your logon username). Note – I am not limiting connections to only localhost

#!/bin/bash
PATH="$PATH:/usr/bin"
export USER="user"
DISPLAY="1"
DEPTH="16"
GEOMETRY="1920x1080"
OPTIONS="-depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"
. /lib/lsb/init-functions
case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;
log_action_begin_msg "Stopping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;
$0 stop
$0 start
;;
esac
exit 0

Make the file executable

sudo chmod +x /etc/init.d/vncserver

Start service

sudo service vncserver start

Client – Assumed Windows

Download TightVNC free client: http://www.tightvnc.com/download.php

For the Remote Host, type “Servername::5091”, where Servername = Your Server’s hostname or IP Address. Then  click Connect

You will be asked for password. Enter password you set while installing vncserver

You should see the GNOME desktop now.

Reference: https://help.ubuntu.com/community/VNC/Servers

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.