Skip to content

Remote Desktop Setup for Ubuntu 24.04 AWS EC2

This guide explains how to set up remote desktop access on an Ubuntu 24.04 AWS EC2 instance so you can connect from a Windows machine.

System Information

This setup is tested on:

  • OS: Ubuntu 24.04 LTS (AWS EC2)
  • Architecture: x86_64
  • Kernel: Linux 6.14.0-1011-aws

XRDP allows you to use Windows' built-in Remote Desktop Connection to connect to your Ubuntu machine.

Installation Steps

  1. Update the system:
sudo apt update && sudo apt upgrade -y
  1. Install desktop environment (XFCE - lightweight):
sudo apt install -y xfce4 xfce4-goodies
  1. Install XRDP:
sudo apt install -y xrdp
  1. Configure XRDP to use XFCE:
echo "xfce4-session" > ~/.xsession
  1. Start and enable XRDP service:
sudo systemctl enable xrdp
sudo systemctl start xrdp
  1. Configure firewall (if ufw is enabled):
sudo ufw allow 3389
  1. Set password for ubuntu user:
sudo passwd ubuntu

Install Firefox Browser

sudo apt install -y firefox

Option 2: VNC Server (Alternative)

VNC provides cross-platform remote desktop access but requires a separate VNC client.

Installation Steps

  1. Install VNC server and desktop:
sudo apt update
sudo apt install -y ubuntu-desktop-minimal tigervnc-standalone-server tigervnc-common
  1. Set VNC password:
vncpasswd
  1. Start VNC server:
vncserver :1 -geometry 1920x1080 -depth 24
  1. Configure firewall:
sudo ufw allow 5901

AWS Security Group Configuration

Important: You must configure your AWS Security Group to allow remote desktop connections.

  1. Go to AWS Console → EC2 → Security Groups
  2. Select your instance's security group
  3. Add inbound rule:
  4. For XRDP:
    • Type: Custom TCP
    • Port: 3389
    • Source: Your IP address (for security)
  5. For VNC:
    • Type: Custom TCP
    • Port: 5901
    • Source: Your IP address (for security)

Connecting from Windows

Using XRDP (Option 1)

  1. Open "Remote Desktop Connection" (built into Windows)
  2. Computer: your-ec2-hostname:3389 or your-ec2-public-ip:3389
  3. Username: ubuntu
  4. Password: The password you set with sudo passwd ubuntu

Using VNC (Option 2)

  1. Install a VNC client (like RealVNC Viewer)
  2. Connect to: your-ec2-hostname:5901 or your-ec2-public-ip:5901
  3. Enter the VNC password you set with vncpasswd

Troubleshooting

XRDP Issues

  • Black screen: Make sure you set the session with echo "xfce4-session" > ~/.xsession
  • Connection refused: Check if XRDP is running: sudo systemctl status xrdp
  • Can't connect: Verify AWS Security Group allows port 3389

VNC Issues

  • Display not found: Start VNC server with vncserver :1
  • Connection timeout: Check AWS Security Group allows port 5901
  • Poor performance: Try reducing color depth: vncserver :1 -depth 16

General Network Issues

  • Verify your EC2 instance's public IP hasn't changed
  • Check that your home/office IP is allowed in the security group
  • Ensure the EC2 instance is running and accessible via SSH

Security Considerations

  • Limit source IPs: Always restrict remote desktop access to your specific IP addresses
  • Use strong passwords: Set complex passwords for user accounts
  • Consider VPN: For production environments, consider accessing through a VPN
  • Disable when not needed: Stop XRDP/VNC services when not in use:
sudo systemctl stop xrdp  # For XRDP
vncserver -kill :1        # For VNC

Performance Tips

  • XFCE is lightweight: We chose XFCE desktop environment for better performance over RDP
  • Adjust resolution: Use appropriate screen resolution for your connection speed
  • Close unused applications: Remote desktop uses bandwidth, so close unnecessary programs
  • Use compression: Some RDP clients offer compression options for slower connections