In this tutorial, I have explained the easy steps to configure GUI for the RedHat 7 & 8 EC2 instance and connect to it using RDP clients.
GUI for Amazon EC2 RHEL 7 & RHEL 8
There are three sections involved in the whole setup. Follow all the three sections explained below to successfully configure the GUI.
Prerequisites
- RHEL 7 or 8 ec2 instance with minimum instance type of t2.medium. The GUI won't load on smaller instance types.
- ec2 instance security group should have an inbound connection to 3389 port.
Installing GUI Components
1. Update the server using the following command.
sudo yum -y update
2. Install the gnome GUI components using the following command.
sudo yum groupinstall -y "Server with GUI"
3. 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. In the next section, we will install the xrdp components to enable remote desktop connections.
Setting up XRDP
1. 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
2. Install xrdp and tiger VNC server.
sudo yum install -y xrdp tigervnc-server
3. Setup SELINUX security using the following commands.
chcon --type=bin_t /usr/sbin/xrdp
chcon --type=bin_t /usr/sbin/xrdp-sesman
4. Start and enable the xrdp service.
sudo systemctl start xrdp
sudo systemctl enable xrdp
5. Enable RDP port on the instance using the following firewall commands.
sudo firewall-cmd --permanent --add-port=3389/tcp
sudo firewall-cmd --reload
6. Set a password for ec2-user . This password will be used to connect to the RDP session.
sudo passwd ec2-user
7. 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 we have the xdrp components and all instance-level settings in the right place. Now let's test out the RDP connection from an RDP client.
In this tutorial, I am using a windows RDP client.
If you are using MAC, you can use the Microsoft Remote Desktop app to connect.
Connecting the Instance Using RDP
1. Open RDP client and type in the public IP of your instance and click connect.
2. If you get a warning message about remote identity, just click yes.
3. Now you will get a xrdp authentication window, enter the credentials and click ok.
4. You will be prompted to enter the password again. Provide the password and proceed to the steps to configure the initial desktop.
5. If it prompts for "cloud user password" provide the root user password you set in step 7.
6. That's it, you will get a GUI session as shown below. If you face any errors do let me know in the comment session.
