Running Ubuntu Desktop on an AWS EC2 instance.

Wajeeh Ahsan
3 min readNov 13, 2020

1. Overview

This tutorial will guide you through the setup of running ubuntu desktop on an AWS EC2 instance using TightVNC on a system running Ubuntu 16.04+.

What you’ll need :

  • Access to an AWS EC2 instance using commandline — This tutorial assumes that you’re logged into the machine using SSH
  • A machine running ubuntu 16.04+
  • Remmina Remote Desktop Client (Pre-installed on 16.04+)

2. Setting up TightVNC on AWS

Let’s install Ubuntu Desktop and TightVNC on your EC2 instance. After logging in to your EC2 instance using the terminal, enter the following commands to install the tools that will be required to run Ubuntu desktop :

sudo apt update
sudo apt install ubuntu-desktop
sudo apt install tightvncserver
sudo apt install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal

After completion, your machine is ready with GUI support but needs some configuration to be done.

3. Configuring the VNC server

In your terminal type the following command to launch VNC server to create an initial configuration file:

vncserver :1

Open the configuration file in editor:

nano ~/.vnc/xstartup

Edit the file to look like so :

#!/bin/sh

export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS

[ -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 &

Great! We’re almost done with the configuration. Now, let’s restart the VNC server by killing it first and then starting it up.

To kill the vnc server and start it again, type the following command:

vncserver -kill :1

vncserver :1

Congratulations, you’re done with the configuration for Ubuntu Desktop.

4. AWS Configuration

We need to make sure that the AWS instance has inbound rules setup to allow connection using VNC. So, head over to your AWS EC2 console and modify the inbound-rules. Add the entry : Custom TCP Rule | TCP | 5901 | Custom | 0.0.0.0/0 | VNC Connect

Save this entry. Done!

5. Connecting to Ubuntu Desktop

Launch Remmina Remote Desktop Client. Then, 1. Choose the connection type as ‘VNC’

  1. Enter your EC2 url along with the port number as 1. For eg. : My EC2 instance URL and the port number as 1 will be
ec2-54-172-197-171.compute-1.amazonaws.com:1

3. Enter the password you provided during the installation of the VNC Server.

4. Connect!

Congratulations, you’ve successfully configured your EC2 instance to run Ubuntu Desktop GUI Support.

Hope you liked the tutorial.

--

--