Create GUI for Ubuntu EC2 Instance
Today we will talk about setting up an ubuntu AMI-based EC2 instance on aws with GUI support. This will allow you to access the instance with the windows remote desktop service.
Log in to the AWS Console
Search for EC2
Let’s start to launch an instance
Put a name as you like. As we intend to work on ubuntu, let’s select the ubuntu AMI with free tier eligibility
Keep the CPU and volume as default,
Create a new key pair for the instance
After creating and downloading the security key pair, let’s move to creating the security group.
We will keep the SSH traffic anywhere, so we can connect from the shell.
Lunch the EC2 instance. After the launching of the instance, go to the attached security group of your instance and we need to add a new inbound rule which helps to remote login. Enter port 3389 will allow remote access to the instance, you can select My IP if you intend to access it alone or if there are multiple users you can use it anywhere
After saving you can see RDP shows up at the security group
Let’s connect to the instance by Instance Connect option, because it’s easy to use.
Great, now we are going to update the ubuntu and setup with the GUI
Let’s update the ubuntu first
sudo apt update
Next, we’ll install the ubuntu-desktop
sudo apt install ubuntu-desktop
This will take a few mins to complete. After completing the ubuntu-desktop next we will need to install the remote desktop for windows RDP, for that we use XRDP on ubuntu.
sudo apt install xrdp
After installing the xrdp, we need to check the status of it
sudo systemctl status xrdp
You can see it’s active and running, so we are good to go forward
Next, we need to add the xrdp user to the SSL Certification center, this will allow us to connect from RDP.
sudo adduser xrdp ssl-cert
After adding the xrdp, we need to allow the RDP port which is 3389 to access.
sudo ufw allow 3389
it should update the rules like above.
Now we are all done with XRDP setup, but we have to set a root password for the user.
sudo passwd
From this command, you will be able to set a new password for your root account.
We are done with the instance shell, and now let’s turn back to our remote desktop application.
Open the Remote Desktop application
Copy the public IP address from your instance details.
Paste on the computer section the RDP app
Go to Display and let’s minimize the size to medium
Click on connect
It will pop the XRDP login screen and ask you for the credentials
keep the session as default, put username: root and password: your root password
This will take you to the ubuntu starting page.