Let’s see how we can launch it on an EC2 instance on AWS using RDP for accessing it.
Ubuntu Mantic is available on AWS Marketplace only, so you need to open the Marketplace, search for Ubuntu Mantic, and subscribe.
After subscribing and agreeing to the terms and conditions, you will have to wait for a couple of minutes before being able to launch it.
The suggested requirements to run Ubuntu Desktop are at least 2 cores and 8GB of RAM, but take into consideration that on remote instances without GPU, the video is being rendered using the CPU.
Regarding disk space, you can fit the whole installation on an 8GB volume, but it won’t be enough for your own applications, so make sure to make some room for your needs.
When selecting or creating a security group, make sure you are allowing SSH and RDP ports (21 and 3389 respectively). You can select the “create a security group” option, which will allow you to enable port 21, but you will need to add the RDP port later (either to the same security group or creating a new one and attaching it to the instance). You can also create a security group before launching the instance.
You can connect either using SSH (using a SSH client such as PuTTY if you are on Windows or the terminal in Linux) or using Instance Connect on the AWS EC2 console, as shown in the next picture:
After login, insert the following commands to install the Ubuntu Desktop packages.
sudo apt-get update && apt-get upgrade -y
sudo apt-get install -y ubuntu-desktop
sudo snap install snap-store --edge
This will download all the Ubuntu Desktop packages and dependencies, so it will take a while. Make sure you don’t get disconnected from the session while doing this step.
Install the xrdp server with the following command:
apt-get install -y xrdp
And configure it to use SSL to get an encrypted connection:
sudo usermod -a -G ssl-cert xrdp
Finally, we need to set up a password for the Ubuntu user:
And restart the service:
systemctl restart xrdp
At this point, you should be able to connect to your instance using RDP. If you do so, you will see a vanilla Gnome desktop without the Ubuntu session, so we need to create a configuration script that will be run on RDP connections.
Using Nano or your favorite text editor, create the following file:
sudo nano /usr/local/bin/ubuntu-session
Insert the following content:
exec /usr/bin/gnome-session --session=ubuntu
And make the script executable:
sudo chmod +x /usr/local/bin/ubuntu-session
Finally, we need to update the session manager to use our new session configuration:
update-alternatives --install /usr/bin/x-session-manager x-session-manager /usr/local/bin/ubuntu-session 60
Open your favorite RDP client and connect to your instance. You can get the IP address from the EC2 console. The connection port is 3389.
I am using Remmina, since I’m on Ubuntu.