This Guide describes how to install VNC Server on Ubuntu 14.04 on Rackspace Cloud with step by step commands. The server becomes a desktop. Previously we described how to Install VNC Server on Ubuntu 12.04 on Rackspace Cloud Server, also we did it with a special version of Debian named NeuroDebian; also we explained the terminology – VNC – Virtual Network Computing. Also, we explained the differences between Server OS and Desktop OS. Both, Ubuntu 12.04 and Ubuntu 14.04 are LTS, that means both will enjoy Long Term Support.
Frequently Asked Questions Related to Guide to Install VNC Server on Ubuntu 14.04 on Rackspace Cloud
Users often ask whether running VNC is legal or illegal. As we are NOT the provider, you must comply with the rules of your country and the country where the Server datacenter is located. Additionally, you must not perform illegal works which are described by the provider, in our case it is Rackspace. For example, as it becomes a desktop, your IP address on the remote server’s browser becomes of Rackspace. VNC or Virtual Network Computing is fully legal in most of the countries. VNC or Virtual Network Computing is intended for good work, not for destructive works.
Please do not change firewall or other security related settings from graphical desktop interface without knowing what you are doing. We will recommend to keep the fresh installation as an image so that you can easily spin up a new instance in case you can not handle the problems out of experiments. In any case of difficulty to login, you always can access the server from console provided by Rackspace.
---
Guide to Install VNC Server on Ubuntu 14.04 on Rackspace Cloud
If you are using Windows OS, use PuTTY like SSH/Telnet client for initial command line works. Create a server from your account. Then select Ubuntu 14.04for this guide to install VNC Server. Choose RAM according to your need. 2 GB RAM will be a sufficient to start, you can use more RAM if you need. After clicking the create button, the server building process will start and you will get the prompt of password proving window. Copy it to a text editor like notepad and after the build process is complete. The step by step screenshots are shown in older guide, new users can follow them.
Now we will SSH to the server once the build process has been completed. First update and upgrade your instance :
1 2 3 4 5 | ssh root@your-IP-address # change your-IP-address # accept the prompt # do update and upgrade apt-get update && apt-get upgrade |
Perform a soft reboot :
1 | reboot |
Now open the sources.list
file to Edit it :
1 | sudo nano /etc/apt/sources.list |
commented out lines will have hash before them, enable the universe
and multiverse
repositories only from one source (either mirror.rackspace or official ubuntu repo; if you use mirror.rackspace, you will not get charged for the bandwidth as it is within ServiceNet). Run apt-get update and apt-get dist-upgrade to check if it throws any error or not.
1 | apt-get update && apt-get dist-upgrade |
We will install GNOME and vnc4server this time :
1 | apt-get install gnome-core xfce4 firefox && apt-get install vnc4server |
If you want to share the setup with multiple users, you should add users like we do for normal SSH usage :
1 2 3 | adduser your-username # force to add password if you are not getting password prompt passwd your-username |
It will ask hundreds of questions, type and complete the process. The command vncserver
will start VNC session :
1 | vncserver |
The above is for root user. If you want to do it as user, you have to run these commands :
1 2 3 4 5 | su - your-username # start vmc vncserver # kill / stop vmc vncserver -kill :1 |
As UNIX or Linux are intended for multiple users by default, the configuration file will be located at :
1 2 3 4 5 6 7 | /home/your-username/.vnc/xstartup # change your-username # to take a backup of the file before editing cp ~/.vnc/xstartup ~/.vnc/xstartup.bak # edit it nano .vnc/xstartup # save it with ^ + O and exit with ^ + X |
We should edit it like to like this :
1 2 3 4 5 6 7 8 9 | #!/bin/sh unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS startxfce4 & [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic & |
We will create a configuration file in etc
directory and create a file :
1 2 3 4 5 6 7 8 | mkdir -p /etc/vncserver nano /etc/vncserver/vncservers.conf # save it with ^ + O and exit with ^ + X # port are 5901 with resolution 1024x768 # add these two lines [..] VNCSERVERS="1:your-username" VNCSERVERARGS[1]="-geometry 1024x768" |
By default vncserver
will not start after a reboot as daemon. We said about how to write bash scripts and this is a situation where we will need a bash script to automate the start process by default by editing the file :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | nano /etc/init.d/vncserver ** Script Starts With # up to end** #!/bin/bash unset VNCSERVERARGS VNCSERVERS="" [ -f /etc/vncserver/vncservers.conf ] && . /etc/vncserver/vncservers.conf prog=$"VNC server" start() { . /lib/lsb/init-functions REQ_USER=$2 echo -n $"Starting $prog: " ulimit -S -c 0 >/dev/null 2>&1 RETVAL=0 for display in ${VNCSERVERS} do export USER="${display##*:}" if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then echo -n "${display} " unset BASH_ENV ENV DISP="${display%%:*}" export VNCUSERARGS="${VNCSERVERARGS[${DISP}]}" su ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}" fi done } stop() { . /lib/lsb/init-functions REQ_USER=$2 echo -n $"Shutting down VNCServer: " for display in ${VNCSERVERS} do export USER="${display##*:}" if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then echo -n "${display} " unset BASH_ENV ENV export USER="${display##*:}" su ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1 fi done echo -e "n" echo "VNCServer Stopped" } case "$1" in start) start $@ ;; stop) stop $@ ;; restart|reload) stop $@ sleep 3 start $@ ;; condrestart) if [ -f /var/lock/subsys/vncserver ]; then stop $@ sleep 3 start $@ fi ;; status) status Xvnc ;; *) echo $"Usage: $0 {start|stop|restart|condrestart|status}" exit 1 esac |
We should chmod it properly to make it executable for the next step :
1 | chmod +x /etc/init.d/vncserver |
We should do two last steps :
1 2 3 | update-rc.d vncserver defaults 99 # reboot reboot |
After the server boots again, for Windows, follow our older guide; for OS X 10.9 upwards, we can directly use vmc://
with IP address, followed by :port-number
to open the VNC session; for Linux, we can use Vino VNC Client. There are client apps for mobile devices like those running Android. Default settings will work out of the box. If does not work, please refer to the OS specific websites. Please check the steps yourself and report us if we have missed any step as it really difficult to remember the steps later after really checking. We will do the needed change after creation of corresponding video guide.
Please do not follow multiple guides as custom filename, path, user name might not match.