How to install Remote Desktop Service on the CentOS
In a scenario where we need to have GUI access on our remote server, it is good to have this cheat sheet in hand. What we will run through in this article is how to install remote desktop service on the CentOS machine. Remote desktop we'll install and configure is
XRDP. Let's check out the steps!
First, we need to install an environment. We'll go by GNOME (this process may take a few minutes to complete):
$ sudo dnf groupinstall "Server with GUI"
Now, since the XRDP is available in EPEL repository, we need to install it:
$ sudo dnf install epel-release
When this is done, we need to install the XRDP service:
$ sudo dnf install xrdp
In the end let's start the XRDP service (if not already started):
$ sudo systemctl start xrdp
And enabling it for the auto start on system boot (if this is something we need, of course - if it's not a single access/use scenario):
$ sudo systemctl enable xrdp
Let's make sure the service is up and running:
$ sudo systemctl status xrdp
Next step would be to tell XRDP what is the GUI session/environment it'll use by editing
/etc/xrdp/xrdp.ini. We need to add the following line at the end of the xrdp.ini configuration file:
Restart the XRDP service:
$ sudo systemctl restart xrdp
And, if there is a firewall on your CentOs machine let's make sure that XRDP port is accessible. Make sure to use the proper IP address from where you want to allow RDP connections (we used 220.127.116.11 as a configuration example only):
$ sudo firewall-cmd --new-zone=xrdp --permanent $ sudo firewall-cmd --zone=xrdp --add-port=3389/tcp --permanent $ sudo firewall-cmd --zone=xrdp --add-source=18.104.22.168/24 --permanent $ sudo firewall-cmd --reload
It is not recommended to open access to RDP from anywhere!
Connecting to XRDP (Remote Desktop)
There is a number of RDP clients out there so, you can choose whichever suits your personal preference. We have tested this solution on a macOS machine so, we'll be using a Microsoft Remote Desktop app available for macOS. Let's check if we can connect to remote desktop service on the CentOS we just installed.
Open the app (after you install it from App store) and choose the option "Add PC". The following dialog opens and you are required to enter the IP address of the server running XRDP service (where we used example 22.214.171.124); the rest of the settings are left as below:
Note that we have the "User account" option left on "Ask when required". We'll leave it like this so that we don't keep sensitive login details stored within the app. When this setting is saved you can see the server in the list as follows:
Alright! Now, double click on the available server in the list opens the login dialog. This happens because we left the "User Account" option on "Ask when required":
Feel free to continue through following warning:
Almost done! Next window will be actual remote desktop powered by GNOME environment:
Voila! We have successfully established a remote desktop connection to our server.