How to Install and Configure a GUI on an AWS EC2 Instance (Ubuntu)

Bhavuk MudgalBhavuk Mudgal
2 min read

🚩 Problem Statement

In many cloud-native environments, developers spin up lightweight Ubuntu EC2 instances on AWS for their development tasks. While this setup works great for command-line work, it becomes a limitation when GUI-based tools are needed.

Recently, our DevOps team was approached by a group of Python developers. Their workflow heavily depends on PyCharm, a popular IDE that offers powerful code navigation, debugging, and project management features. However, when they launched their Ubuntu-based EC2 development instances, they realized:

  • Ubuntu EC2 instances are headless by default, meaning no desktop environment is available.

  • PyCharm, being a GUI-based tool, requires a graphical interface to function.

  • They needed a lightweight, performant, and secure GUI setup that wouldn’t require re-provisioning or large-scale infrastructure changes.

They turned to the DevOps team to solve this.

✅ Solution

As DevOps/SRE professionals, we approached the problem with two goals:

  1. Minimal setup — Easy to install and maintain.

  2. Remote accessibility — Developers should be able to access the GUI from their local systems.

🔧 Step-by-Step Guide to Install GUI on an AWS EC2 Ubuntu Instance

Note: All commands are in Italic font only.

  1. Login to the development machine: ssh -i key.pem ubuntu@ip-address-of-ec2-instance

  2. Switch to root user: sudo su -

  3. Now, to setup and configure GUI, run the following commands in sequence.

apt update -y

apt upgrade -y

sed -i ‘s/^PasswordAuthentication no/PasswordAuthentication yes/’ /etc/ssh/sshd_config

/etc/init.d/ssh restart

adduser username #choose a username of your choice and set the password as well

visudo

Make an entry in the file similar to this:

sudoers file to create a superuser

Save and quit the file: :wq + Enter

apt install xrdp xfce4 xfce4-goodies tightvncserver -y

hostnamectl set-hostname hostgui #choose a hostname of your choice

systemctl restart systemd-hostnamed

4. Now logout and log back in as root user

su — username

echo xfce4-session> ~/.xsession

sudo cp ~/.xsession /etc/skel

sudo sed -i ‘0,/-1/s//ask-1/’ /etc/xrdp/xrdp.ini

sudo service xrdp restart

sudo shutdown -r now

5. Log back in and become root again: sudo su -

apt-get install putty -y

6. Now try RDP to the instance with new username and password

7. For RDP:

type windows+R >>>> mstsc >>>> enter ip-address of the instance>>>> user ID and Password

8. This finishes the installation and configuration on GUI on an AWS EC2 Instance

YouTube Video URL for step-by-step instructions: https://youtu.be/98b7qNurXyw

GitHub Repo: https://github.com/bhavukm/Install-GUI-On-AWS-EC2.git

0
Subscribe to my newsletter

Read articles from Bhavuk Mudgal directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Bhavuk Mudgal
Bhavuk Mudgal