Amazon EC2
Ubuntu server
GUI setup
cloud computing
server configuration

How To Set Up GUI On Amazon EC2 Ubuntu server

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

Running a GUI on an Ubuntu EC2 instance is useful for browser based admin tools, visual data apps, or temporary desktop workflows. The safest approach is to install a lightweight desktop, expose remote desktop through restricted network rules, and keep SSH as your recovery path. This guide uses XFCE and XRDP because they are easy to maintain on Ubuntu.

Choose a Desktop and Size the Instance

A full desktop environment consumes memory and CPU, so start with instance sizing before installing packages. For basic remote administration, a t3.small or t3.medium is usually enough, while heavy graphical workloads need larger instances.

For desktop choice:

  • XFCE is lightweight and responsive for remote sessions.
  • GNOME has richer features but uses more memory.
  • LXQt is very light but may require extra tuning for usability.

Keep swap configured if memory is tight. A GUI that constantly hits swap will feel unresponsive even with low network latency.

Install XFCE and XRDP on Ubuntu

Update the host, install XFCE and XRDP, then enable XRDP service.

bash
1sudo apt update
2sudo apt upgrade -y
3sudo apt install -y xfce4 xfce4-goodies xrdp
4
5# Make XRDP use XFCE session
6cat > ~/.xsession <<'EOF_X'
7startxfce4
8EOF_X
9
10sudo systemctl enable xrdp
11sudo systemctl restart xrdp
12sudo systemctl status xrdp --no-pager

Allow XRDP to read SSL cert group on Ubuntu:

bash
sudo adduser xrdp ssl-cert
sudo systemctl restart xrdp

At this point, port 3389 is listening on the instance. Do not open it to the internet broadly.

Configure EC2 Security Group Safely

In AWS, edit the EC2 security group inbound rules. A safe baseline is:

  • SSH 22 allowed only from your office IP or VPN range.
  • RDP 3389 allowed only from your trusted IP range.

You can apply the rule from AWS CLI:

bash
1aws ec2 authorize-security-group-ingress \
2  --group-id sg-0123456789abcdef0 \
3  --protocol tcp \
4  --port 3389 \
5  --cidr 203.0.113.24/32

Use your actual security group ID and your real public IP block. Keep the rule as narrow as possible.

Connect and Validate the Desktop Session

From your local machine, use any RDP client and connect to EC2_PUBLIC_IP:3389 with your Ubuntu username and password. If your policy requires no direct RDP exposure, tunnel through SSH first.

bash
ssh -L 13389:localhost:3389 ubuntu@EC2_PUBLIC_IP

Then connect your RDP client to localhost:13389. This keeps RDP traffic inside the encrypted SSH session.

After login, validate:

  • Desktop launches without blank screen.
  • Clipboard and keyboard layout behave as expected.
  • CPU and memory usage remain stable under normal work.

Check logs when troubleshooting:

bash
sudo journalctl -u xrdp --no-pager | tail -n 100
cat ~/.xsession-errors | tail -n 100

Hardening and Operational Notes

A GUI server is usually higher risk than a CLI-only host, so treat it as a managed endpoint.

Practical hardening steps:

  • Use an IAM controlled workflow for instance access and audit changes.
  • Keep automatic security updates enabled on Ubuntu.
  • Stop or terminate GUI instances when not needed.
  • Avoid running production databases on the same host as a user desktop.

If you need persistent team access, consider AWS Systems Manager Session Manager plus browser based remote tools, since that can reduce exposed network ports.

Common Pitfalls

  • Opening port 3389 to 0.0.0.0/0. Restrict access to trusted source ranges only.
  • Installing a heavy desktop on a small instance. Use XFCE first and monitor memory.
  • Forgetting ~/.xsession setup, which causes black screen after login.
  • Relying only on GUI access. Keep SSH working for recovery and automation.
  • Ignoring patch cadence. GUI related packages need regular security updates.

Summary

  • Use a lightweight desktop such as XFCE for better EC2 responsiveness.
  • Install and enable XRDP, then validate service and login flow.
  • Restrict network access with tight security group rules.
  • Prefer SSH tunneling or private networking for remote desktop sessions.
  • Treat GUI instances as short lived, patched, and monitored infrastructure.

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.