How to install and configure GUI on AWS EC2 Instance for Linux

Amazon EC2 instances generally do not come with the Graphical User Interface, and most of the operations are done using SSH client like Putty but if you would like to access the GUI of that particular instance then it can be achieved very easily. You just need to install some GUI essential on your EC2 instance.

In this tutorial, I have explained step by step with screenshots to configure GUI for both RHEL 8 and Ubuntu 18.04

Red Hat Enterprise Linux 8 – Step by Step process for installing GUI

 

 

We mostly use free tier eligible instance for our hands on lab or personal use but in case of RHEL 8, it will not match OS requirements and will give timeout errors. So its better to use t2.small or above instance.

Security group inbound traffic configured for ssh and RDP access (22 and 3389). RDP is mandatory to access the GUI using remote Desktop Client.

 

  • Now, Connect to the Server using SSH Client putty and Update the server using the following command.
sudo yum -y update

  • Install the gnome GUI components using the following command.
sudo yum groupinstall -y "Server with GUI"

  • Issue the following commands to start the GUI during boot.
sudo systemctl set-default graphical.target

sudo systemctl default

Now, we have all the essential GUI components installed on the server. So, we will install the xrdp components to enable remote desktop connections.

 

  • Add the xrdp repository to your instance using the following command.
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm

  • Setup SELINUX security using the following commands.
chcon --type=bin_t /usr/sbin/xrdp

chcon --type=bin_t /usr/sbin/xrdp-sesman
  • Start and enable the xrdp service.
sudo systemctl start xrdp

sudo systemctl enable xrdp

  • Enable RDP port on the instance using the following firewall commands.
sudo firewall-cmd --permanent --add-port=3389/tcp

sudo firewall-cmd --reload

  • Set a password for ec2-user . This password will be used to connect to the RDP session.
sudo passwd ec2-user
  • Set password for root as you will be prompted for cloud user password for network proxy and color. Login as root and set the password.
sudo su

passwd
  • Now, Open the remote Desktop Connection app if you are using Windows on local and give the ip address of EC2 instance in Username field. Give permissions and you will be prompted to your instance GUI.

  • Provide the credentials that you setup for your RHEL instance, Username : ec2-user, Password : ******

  • Now you have successfully installed GUI and you will be able to see your screen as per below screenshots.

 

UBUNTU 18.04 – Step by Step process for installing GUI

 

Similarly, like RHEL 8 in the above tutorial, we can access UBUNTU desktop as well by following below commands.

 

  • Connect to the Server using SSH Client putty and you to make sure that RDP port is enabled on your UBUNTU instance. Update the server and hit below commands. 
sudo apt-get update -y   

sudo apt-get install lxde -y
  • Install xrdp to establish a remote desktop connecton using the below command
sudo apt-get install xrdp -y
  • Set the password using below command
sudo passwd ubuntu
  • Start the windows remote desktop client and enter the public DNS or the public IP of your server instance and hit connect. Then you will be prompted to xrdp screen.

 

  • So now you have accessed GUI for your Ubuntu instance as well.

 

I hope you have enjoyed reading this article.

 

Be the first to comment

Leave a Reply

Your email address will not be published.


*