How To Enable GUI On AWS EC2 Ubuntu server

As you may know, by default the Ubuntu images (and others Linux distros too) don’t come with X11/Xorg or GUI enabled. This is fine for the majority of the cases, but some deployments may need GUI, for example if you want to install Security Onion on the Ubuntu Server. On this post we will detail how to enable the GUI on a Ubuntu 18.04 AWS Linux Instance. Once you installed the GUI essentials on your server, you can access it via windows remote desktop client. If you are using Linux, then you can use Reminna Remote Desktop Client. In order to have a GUI, a lightweight LXDE desktop has to be installed on your server. We will go through the steps to achieve this below.

How to enable the GUI on a Ubuntu 18.04 AWS Linux Instance

How to enable the GUI on a Ubuntu 18.04 AWS Linux Instance

Connect to Ubuntu server using SSH

Connect to the server using ssh client. If you are using a Linux machine you can connect following the command:

ssh -i "key.pem" ubuntu@ec2-3-95-251-182.compute-1.amazonaws.com

where key.pem is the SSH key associate to the instance, ubuntu is the username and ec2-3-95-251-182.compute-1.amazonaws.com is the Public DNS for the Linux machine

Once you got access to the instance proceed to the next step:

Update Ubuntu Server and install LXDE

Update the server and install lxde using the following commands.

sudo apt-get update -y   
sudo apt-get install lxde -y

This last command may take a while as it needs to install all the dependencies to have a working GUI on the system and they are not shipped with the image by default.

Now we can install xrdp to establish a remote desktop connection. Use the following command to install xrdp

sudo apt-get install xrdp -y

Set a password for the default user “ubuntu”

Set a password for the default user “ubuntu”, as remote desktop connection requires username and password.

sudo passwd ubuntu

Allow inbound RDP connections (TCP/3389)

Allow inbound RDP connections (TCP/3389) for the security group associated in AWS to the instance. On our example the security group associated to the instance is launch-wizard-3 so we will add a rule to allow TCP/3389 from our IP address only.

rdp securitygroup associated in AWS to the instance

Note; You need to replace 1.2.3.4 with your own IP address

Connect to Ubuntu server using Remote Desktop client

Start the windows remote desktop client and enter the public DNS or the elastic IP of your server instance and hit connect. If you are using Linux you can connect with Reminna Remote Desktop Client

If you got a error message like the following:

You requested an H264 GFX mode for server XYZ, but your libfreerdp does not support H264. Please check Color Depth setttings.

Then you need to set the Color Depth to 16bpp on Reminna. To do that, click on the green plus sign

RDP-error1 windows remote desktop client

You will see the settings options for the default profile. On Color Depth, select ‘high color 16bpp’, then Click on ‘Save as Default’

RDP-error2 settings options

You should now be able to connect and get the logon pop-up

rdp-3 to connect  logon pop-up

type your credentials and that is all, you should see the GUI now:

GUI On AWS EC2 Ubuntu server

This post about ‘How To Enable GUI On AWS EC2 Ubuntu server’, has been written by our Principal Consultant Oscar Pucheta.