Remote Desktop Ubuntu 16.04: How To Use an Ubuntu UI Remotely

Overview
INAP offers access to virtual or bare metal servers in many ways.  For customers who wish an Ubuntu desktop user interface (UI) as opposed to using solely a command line interface (CLI) tools or secondary UI such as cPanel or Plesk, this article will show how to set up that remote desktop session using standard open source tools and minimal CLI expertise.

This would be valuable for:

  • Clients using OS level hosting for their first time
  • Clients with small requirements
  • Clients that don’t have a large staff but are somewhat familiar with Linux UI

Software Requirements
These will be installed during the process below:

Server:

  • Xfce4
    • A free and open-source desktop environment for Unix operating systems like Linux, Ubuntu, etc.
  • Xfce4-goodies
    • Additional software and artwork related to Xfce but not part of the official release
  • Tightvncserver
    • A free, remote control software package which allows the user to see the remote desktop of the machine and control it with a local system mouse and keyboard

Client:

  • puTTy
    • A free, open-source SSH and telnet client which will allow access via the CLI to a server.
  • realVNC, tigerVNC, or tightVNC
    • A series of free remote access software tools.

Installing GNOME and VNC

  • Log in to your Linux server as root user via SSH
  • ~ sudo apt-get update

P1

  • ~ sudo apt-get install xfce4 xfce4-goodies tightvncserver

Picture2
When asked whether you want to continue select  “Y”
Picture3
To complete the VNC server’s initial configuration, use the vncserver command to set up a secure password:

  • ~ vncserver

After you set up your access password, you will be asked if you would like to enter a view-only password. Users who log in with the view-only password will not be able to control the VNC instance with their mouse or keyboard. This is a helpful option if you want to demonstrate something to other people using your VNC server.
Picture4

  • Set passwordvnc

This allows a password to be set used accessing VNC desktops
Picture5

Configuring VNC for Remote Access to the Desktop
Editing the Startup File

The VNC server needs to know what commands to perform when it starts up. These commands are located in a configuration file called xstartup. The VNC server has an xstartup file preloaded already, but some different commands are required for the XFCE desktop.

When VNC is first set up, it launches a default server instance on port 5901. This port is called a display port, and is referred to by VNC as :1. VNC can launch multiple instances on other display ports, like :2, :3, etc. When working with VNC servers, remember that :X is a display port that refers to 5900+X.

As the way the VNC server is configured will be altered, the VNC server instance currently running on port 5901 will need to be stopped.

~ vncserver –kill :1
Picture6
Before configuring the new xstartup file, back up the original in case it is needed later.
~ mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
Picture7
Now a new xstartup file can be created with with nano (text editor) and insert the following commands to start VNC Server upon server startup:
~nano ~/.vnc/xstartup
Picture8
#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &

Ctrl+X to save it
Picture9
Grant this file executable privileges:
~ sudo chmod +x ~/.vnc/xstartup
Picture10
A restart of the vncserver service may be required for host connection.
~vncserver
Picture11
New ‘X’ desktop is ubuntu16:1, based on the name of the server in question being ubuntu16.

Configuring a Tunnel to the Linux Desktop

  • Open PuTTy
  • In the Category section, select Connection > SSH > Tunnels
    Picture12
  • Type and enter the following, and then click Add:
    • Source port — Type 580, plus the port you specified in the VNC configuration file. Because we used port 1 in that example, here we would enter 5801.
    • Destination — Type <IP Address of the server>:580, plus the port you specified in the VNC configuration file. Because we used port 1 in that example, here we would enter 5801.
  • Type and enter the following, and then click Add:
    • Source port — Type 590, plus the port you specified in the VNC configuration file. Because we used port 1 in that example, here we would enter 5901.
    • Destination — Type <IP Address of the server>:590, plus the port you specified in the VNC configuration file. Since we used port 1 in that example, here we would enter 5901.

Picture13

  • In the Category section, navigate to Session.
  • In the Saved Sessions field, type VNC Tunnel, and then click Save.

Picture14
Make sure that the server has port 5901 to allow VNC access.  Adjust this within Horizon or via the CLI

picture123

Accessing the Linux Desktop
Each time the Linux remote desktop is accessed, the SSH tunnel configured must be loaded. Then open an Internet browser that has Java applets enabled to log in to VNC.
Access the Linux Desktop with a VNC client. Recommended client options are below.

  • TigerVNC
  • TightVNC
  • RealVNC
  • Open PuTTY, select the saved session, click Load, and then log in to the server. This opens the SSH Tunnel.
  • Open the preferred VNC Client, type hostname:590[n] (where [n] is the port specified in the VNC configuration file, and then press Enter.

Picture15
This opens a secure connection from the Linux server to your desktop and a screen similar to the one below should be seen, with a traditional GUI view.

Picture16