VNC (Virtual Network Computing, is a tool that allows you to connect to the GUI (Graphical User Interface) of linux GDE (Graphical Desktop Environment). This allow you to interact with Ubuntu using mouse and Keyboard in a GUI.

  1. Install xfce and choose the display manager (gdm3) in this tutorial.
  2. Install tightvncserver
  3. Configure tightvncserver
  4. Modified the ~/.vnc/xstartup file.
  5. Allowing access through host firewall (iptables)
  6. Start tightvncserver

Step 1. Installing the GDE for Ubuntu. You can select either (gdm3/lightdm) it doesn’t really matters for lab environment. We will select gdm3 for this tutorial.

sudo apt install xfce4 xfce4-goodies

Step 2. Install TightVNC server

sudo apt install tightvncserver

Step 3. Configure TightVNC server. Start the server to enter the initial password. You can also use vncpasswd to change the password. There is a maximum of 8 characters for the Password and anything after that will be truncated.

vncserver

Step 4. Before modifying the ~/.vnc/xstartup file you need to kill the vncserver process (Xtightvnc)

vncserver -kill :1

or list the process and issue the kill -9 <pid> command

ps
kill -9 <pid>

Now we can modify the ~/.vnc/xstartup file add the following to the end of the file.

nano ~/.vnc/xstartup

# Add this new line to the bottem of the file.
startxfce4 &

If you have created a new file remember to make it executable.

chmod +x ~/.vnc/xstartup

ls -la ~/.vnc/xstartup you should see the file is not executable.

Once you have done this you can launch the vncserver again. This should avoid the grey screen that alot of us beginner faces.

You can open the firewall ports, in this example using iptables. However to take note that the tightvnc only support password length of 8 characters so the password might not be strong enough against attacks. It will be better to use ssh tunnel to access the VNCServer. However if you still needs to open the ports through firewall below is a sample.

/sbin/iptables -A INPUT -p tcp -m tcp –dport <vnc port> -j ACCEPT
/sbin/iptables -A INPUT -p udp -m udp –dport <vnc port> -j ACCEPT