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.
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.
Allow XRDP to read SSL cert group on Ubuntu:
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
22allowed only from your office IP or VPN range. - RDP
3389allowed only from your trusted IP range.
You can apply the rule from AWS CLI:
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.
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:
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
3389to0.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
~/.xsessionsetup, 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
- How to setup AWS CloudWatch''s agent at Ubuntu to get correct custom metrics like cpu, memory and disk usage
- How to setup Kubernetes NLB Load Balancer with target group IP based AWS?
- How to share an EFS volume across multiple namespaces
- How to simplify aws DynamoDB query JSON output from the command line?
- How to solve -Cannot use import statement outside a module in AWS lambda console
- How to solve Error loading state AccessDenied Access Denied status code 403 when trying to use s3 for terraform backend?
- How to specify all ports in Security group - CloudFormation
- How to specify AWS Access Key ID and Secret Access Key as part of a amazon s3n URL

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack 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.