Remote desktop access to CentOS Linux VPS is super easy using Windows remote desktop connection. Let’s head to enable remote desktop on CentOS Linux by installing XRDP on CentOS 8.x VPS and configure it for GUI remote connection.
The XRDP is an open-source implementation of the Microsoft Remote Desktop Protocol (RDP) that allows you to control a remote system graphically. With RDP, you can log in to the remote machine and create a real desktop session the same as if you had logged in to a local system.
The article explains the process of install and configure XRDP on CentOS VPS and connect it from Windows 10 remote desktop.
If you like to have remote access to CentOS VPS using SSH, head to configure SSH on CentOS Server article.
Installing Desktop Environment on CentOS
A Linux server usually comes without GUI, and the desktop environment not installed by default. If the CentOS VPS you have to connect to doesn’t have GUI, the first step is to install the desktop environment to have access a graphical interface remote desktop.
The Gnome is the default desktop environment in CentOS 8. To install Gnome on your remote machine, run the following command.
sudo yum groupinstall "Server with GUI"
It will take time and depending on your system speed and download speed to complete the installation of the Gnome packages and dependencies.
Install and Enable Remote Desktop on CentOS
The XRDP is available in the EPEL software repository. If EPEL doesn’t enable on your system, try to allow it by typing the following command.
sudo yum install epel-release
You might be faced with the below error. In this case, simply enable the epel package on your system.
[root@enlinux ~]# yum install epel-release Updating Subscription Management repositories. Last metadata expiration check: 0:14:11 ago on Mon 24 Aug 2020 10:27:24 AEST. No match for argument: epel-release Error: Unable to find a match: epel-release [root@enlinux ~]#
Now the system is ready for installing the XRDP package which included in the standard CentOS 8 repositories. Type the following command to install XRDP.
sudo yum install xrdp -y
When the installation process has done, start the XRDP service and enable it with the following commands.
sudo systemctl enable xrdp sudo systemctl start xrdp
Type the following command to verify that XRDP is enabled and running on your machine.
sudo systemctl status xrdp
Configuring XRDP on CentOS Linux
You can find the XRPD configuration files in the
/etc/xrdpdirectory. For regular XRDP connections, you only need to set XRDP to use Gnome. To edit it the file, open the following file in your text editor and past the (exec gnome-session) at the end of the text.
sudo nano /etc/xrdp/xrdp.ini
Now just add the following line at the end of the file. Check the screenshot of xrdp.ini file to make sure you are doing as it should be.
When you have done, just save the file and restart the XRDP service with the following command.
sudo systemctl restart xrdp
Configuring Firewall for Remote Desktop
The default remote desktop port is 3389. So, as usual, the XRDP is listening to 3389 port on all interfaces. To make the machine Firewall aware that we are using the remote desktop port, we should add the port 3389 to the Firewall and allow it.
The following command will allow the port 3389 to accept incoming network traffic from anywhere.
sudo firewall-cmd --add-port=3389/tcp --permanent
sudo firewall-cmd --reload
All good. It’s enough to allow remote desktop in the Linux Firewall. But to allow only for a specific network or ranges of IP addresses you need to type the following command. It’s a good practice for the production environment.
sudo firewall-cmd --new-zone=xrdp --permanent
sudo firewall-cmd --zone=xrdp --add-port=3389/tcp --permanent
sudo firewall-cmd --zone=xrdp --add-source=192.168.1.0/24 --permanent
sudo firewall-cmd --reload
Verifying Remote Desktop XRDP
The final stage, verify the XRDP server to make sure it is up and running and listening to remote desktop port 3389. The netstat command helps to check it.
netstat –atnp | grep 3389
Connect CentOS Server Using Remote Desktop
To run remote desktop connection in Windows 10, press (Windows + R) key to open the Run. Then type (mstsc) and press enter.
Type your CentOS Linux IP address and try to connect to the XRDP using Windows remote desktop.
Accept the remote desktop connection certification prompt and go ahead to login page.
Type the the CentOS server username and password then connect it.
The result should be a friendly clean graphical interface of CentOS server like the below screenshot.
The final note: The Linux distros are capable of having access graphically using remote desktop protocol software. But the power of terminal and command lines are not in a GUI.