Skip to content

Install GUI (graphical desktop) on Amazon EC2 instances running Ubuntu Linux

6 minute read
Content level: Intermediate
4

Steps to install desktop environment, desktop manager and Amazon DCV high performance remote display protocol server on Ubuntu Linux

Overview

This article suggests how you can install GUI (Graphical User Interface) on Amazon EC2 instances running Ubuntu Linux, and access it using Amazon DCV remote display protocol.

This article applies to Ubuntu Linux on AWS only. Similar articles are available for AL2, AL2023, RHEL/Rocky Linux and SLES 15

GPU instance

The following options are available if you are using NVIDIA GPU EC2 instance:

Notice

Your use of DCV is subject to DCV end user license agreement

Requirements

Supported Ubuntu versions

The following versions are supported by Amazon DCV server

  • Ubuntu 24.04 (x86_64 and arm64)
  • Ubuntu 22.04 (x86_64 and arm64)

EC2 instance prerequisites

  • EC2 instance with 2 GiB or more memory
  • Attached security group allows inbound TCP and UDP port 8443 from your IP
  • More than 3 GB free disk space to install graphical desktop components and DCV server
  • Attached EC2 IAM role with the below policy for license validation. Replace REGION with your instance AWS Region code. Alternatively, attach AmazonS3ReadOnlyAccess managed policy.
{
    "Version": "2012-10-17",
    "Statement": [
       {
           "Effect": "Allow",
           "Action": "s3:GetObject",
           "Resource": "arn:aws:s3:::dcv-license.REGION/*"
       }
    ]
}

Installing DCV

Install desktop environment and desktop manager

Install GNOME desktop and disable Wayland protocol. Disable upgrade prompt to newer LTS release.

sudo apt update
sudo apt install -y ubuntu-desktop-minimal
sudo sed -i '/^\[daemon\]/a WaylandEnable=false' /etc/gdm3/custom.conf
sudo systemctl set-default graphical.target
sudo sed -i "s/Prompt=lts/Prompt=never/g" /etc/update-manager/release-upgrades

Install DCV server

Install DCV server, web client and virtual session support, and enable server daemon

cd /tmp
OS_VERSION=$(. /etc/os-release;echo $VERSION_ID | sed -e 's/\.//g')
curl -L -O https://d1uj6qtbmh3dt5.cloudfront.net/nice-dcv-ubuntu$OS_VERSION-$(arch).tgz
tar -xvzf nice-dcv-ubuntu$OS_VERSION-$(arch).tgz && cd nice-dcv-*-$(arch)
sudo apt install -y ./nice-dcv-server_*.deb
sudo apt install -y ./nice-dcv-web-viewer_*.deb
sudo apt install -y ./nice-xdcv_*.deb
sudo usermod -aG video dcv
sudo systemctl enable dcvserver

Use Xdcv with console session

For non-GPU instance, configure console session to be served by Xdcv instead of Xorg for dynamic resizing and multi-monitor support

sudo dpkg-divert --package nice-xdcv --divert /usr/bin/Xorg.orig --rename /usr/bin/Xorg
sudo ln -sf /usr/bin/Xdcv-console /usr/bin/Xorg

If you have NVIDIA drivers installed, you may want to configure GPU-accelerated Xorg console session instead

if [ -f /usr/bin/nvidia-xconfig ]; then
  sudo /usr/bin/nvidia-xconfig --preserve-busid --enable-all-gpus
fi

Configure DCV server

Configure console session, file transfer and printing support

USER=ubuntu
sudo sed -i "/^\[session-management\/automatic-console-session/a owner=\"$USER\"\nstorage-root=\"%home%\"" /etc/dcv/dcv.conf
sudo sed -i "s/^#create-session/create-session/g" /etc/dcv/dcv.conf

sudo apt install -y cups
sudo usermod -a -G lpadmin dcv
sudo systemctl enable --now cups

Restart X server and DCV server

sudo systemctl isolate multi-user.target && sudo systemctl isolate graphical.target
sudo systemctl stop dcvserver && sudo systemctl start dcvserver

Set user password

Specify a strong password for login user

sudo passwd ubuntu

Verify installation

To verify

dcv list-sessions

You should get the below output indicating a console DCV session

Session: 'console' (owner:ubuntu type:console)

Access graphical desktop environment

Clients

DCV offers Windows, Linux, macOS and web browser clients.

You can connect to DCV server using web browser client at https://<EC2-IP>:8443 (where <EC2-IP> is your EC2 instance IP address). Native clients provide better user experience and additional features, and can be downloaded from Amazon DCV site.

Login as ubuntu with your configured password

Do ensure that EC2 instance security group allow inbound TCP and UDP 8443 from your IP

Web browser client

Enter image description here

EC2 Install Script

You can use the below as install script (or user data) on a new Ubuntu Linux EC2 instance.

#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
sudo apt update
sudo apt install -y ubuntu-desktop-minimal
sudo sed -i '/^\[daemon\]/a WaylandEnable=false' /etc/gdm3/custom.conf
sudo systemctl set-default graphical.target
sudo sed -i "s/Prompt=lts/Prompt=never/g" /etc/update-manager/release-upgrades

cd /tmp
OS_VERSION=$(. /etc/os-release;echo $VERSION_ID | sed -e 's/\.//g')
curl -L -O https://d1uj6qtbmh3dt5.cloudfront.net/nice-dcv-ubuntu$OS_VERSION-$(arch).tgz
tar -xvzf nice-dcv-ubuntu$OS_VERSION-$(arch).tgz && cd nice-dcv-*-$(arch)
sudo apt install -y ./nice-dcv-server_*.deb
sudo apt install -y ./nice-dcv-web-viewer_*.deb
sudo apt install -y ./nice-xdcv_*.deb
sudo usermod -aG video dcv
sudo systemctl enable dcvserver

USER=ubuntu
sudo sed -i "/^\[session-management\/automatic-console-session/a owner=\"$USER\"\nstorage-root=\"%home%\"" /etc/dcv/dcv.conf
sudo sed -i "s/^#create-session/create-session/g" /etc/dcv/dcv.conf

sudo apt install -y cups
sudo usermod -a -G lpadmin dcv
sudo systemctl enable --now cups

sudo dpkg-divert --package nice-xdcv --divert /usr/bin/Xorg.orig --rename /usr/bin/Xorg
sudo ln -sf /usr/bin/Xdcv-console /usr/bin/Xorg

sudo systemctl isolate multi-user.target && sudo systemctl isolate graphical.target
sudo systemctl stop dcvserver && sudo systemctl start dcvserver

Restart your EC2 instance and set ubuntu user password

Additional information

For help with DCV, refer to DCV Administrator Guide and User Guide

For help navigating graphical desktop, refer to Learn GNOME

DCV sessions

Amazon DCV on Linux offers two types of sessions: console sessions and virtual sessions. This article use console session that is served by Xdcv. Virtual sessions support multiple concurrent sessions.

To switch to virtual session, connect to EC2 instance as ubuntu, disable console session, configure multi-user.target (optional) and reboot

sudo sed -i "s/^create-session/#create-session/g" /etc/dcv/dcv.conf
sudo systemctl restart dcvserver
sudo systemctl set-default multi-user.target
sudo systemctl isolate multi-user.target

sudo reboot

You will need to create a virtual session manually

USER=ubuntu
dcv create-session $USER --owner $USER --storage-root %home% --type virtual

To verify that virtual session has been created

sudo dcv list-sessions

Output should be similiar to below

 Session: 'ubuntu' (owner:ubuntu type:virtual)

Refer to Using the command line on a Linux Amazon DCV Server for more information

Other options

Consider managed EUC (End User Computing) services such as Amazon WorkSpaces

Install prerequisites including desktop environment and Amazon DCV Server from Amazon DCV Administrator Guide

To quickly get up and running with DCV for internal testing, you can use CloudFormation template at DCV CloudFormation page.

You can also explore amazon-ec2-nice-dcv-samples CloudFormation templates to provision your own EC2 instances with graphical desktop environment, DCV server and other features such as multiple virtual sessions support and GPU driver installation.

AMIs preconfigured with graphical desktop environment are available from AWS Marketplace.

AWS
EXPERT

published 2 years ago12K views

2 Comments

Hello @MikeLim

Thank you for your post, this is very helpful. I have a few questions.

It is practically impossible for me to get my corporate infra team to get the DCV port 8443(TCP & UDP)? Is this something that I can tunnel and use ssm to portforward and access through 443? Is it possible to have multiple users concurrently access their own Gnome sessions in a big fat ec2 instance?

Looking forward to your thoughts. Thank you! g

replied a year ago

Hi Govardhanen Gopal,

Thank you for the queries. SSM is designed for remote administration; and may not provide optimal experience for remote graphical access.

There are other solutions that allow graphical access from HTTPS port 443, and also multiple GNOME sessions. For example, the GitHub repo mentioned in the article has option for HTTPS reverse proxy and multiple virtual sessions support. We do need to understand your use case in more detail. Can you reach out to your AWS account team? We can follow up from there. Thanks!

Mike

AWS
EXPERT

replied a year ago