Skip to content

Instantly share code, notes, and snippets.

@andreswebs
Last active April 19, 2024 03:22
Show Gist options
  • Save andreswebs/4ced52173fab721466a103543847b363 to your computer and use it in GitHub Desktop.
Save andreswebs/4ced52173fab721466a103543847b363 to your computer and use it in GitHub Desktop.
Set up a desktop environment accessible via RDP on an AWS EC2 instance running Ubuntu

add a non-root user with sudo permissions

(The username in this example is desktop.)

sudo addgroup --gid 2000 desktop
sudo adduser \
    --gid 2000 \
    --uid 2000 \
    --gecos "" \
    --disabled-login \
    desktop
sudo usermod -a -G sudo desktop
echo "desktop  ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/desktop

Set a password for the desktop user:

sudo passwd desktop

install and configure desktop environment (XFCE)

sudo apt update
sudo apt upgrade
sudo apt install --yes xubuntu-desktop
echo xfce4-session | sudo tee /home/desktop/.xsession

cat <<EOF | sudo tee /etc/polkit-1/localauthority/50-local.d/45-allow-colord.pkla
[Allow Colord all Users]
Identity=unix-user:*
Action=org.freedesktop.color-manager.create-device;org.freedesktop.color-manager.create-profile;org.freedesktop.color-manager.delete-device;org.freedesktop.color-manager.delete-profile;org.freedesktop.color-manager.modify-device;org.freedesktop.color-manager.modify-profile
ResultAny=no
ResultInactive=no
ResultActive=yes
EOF

install and enable xrdp service

sudo apt install --yes xrdp
sudo systemctl start xrdp
sudo systemctl enable xrdp

connect

Now it should be possible to connect to the instance IP via RDP using the desktop username and password.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment