11.05.2023

Installing and configuring an RDP Server on CentOS 7

In this guide, we’ll show you how to install xRDP on a remote CentOS 7 computer and how to connect to it through remote desktop connection. We will also show you how to install and connect to various desktop environments on a remote CentOS 7 computer.

xRDP is a free, open-source Remote Desktop Protocol server that allows non-Windows operating systems to provide full-featured remote desktop capabilities.

xRDP is fully compatible with rdesktop, FreeRDP, and even with Microsoft Remote Desktop Client (mstsc.exe).

Requirements:

Update the packages installed on the system:

$ sudo yum -y update

Then install the necessary packages:

$ sudo yum install -y epel-release
$ sudo yum install -y xrdp
$ sudo systemctl enable xrdp
$ sudo systemctl start xrdp

If you are using FirewallD, open port 3389/TCP for RDP:

$ sudo firewall-cmd --add-port=3389/tcp --permanent
$ sudo firewall-cmd --reload

Set your preferred desktop environment

Now we can set the desktop environment that we will use. In this guide, we will try out Xfce, MATE, and GNOME.

Note: if you cannot connect via Remote Desktop Connection after installing the desktop environment, open port 3389/TCP using the firewall-cmd command mentioned above.

Install the XFCE Workspace

Xfce is one of the lightest desktop environments. It is fast, consumes little system resources, but remains visually attractive. Also, she has a very active community, so many customization options are available.

To install Xfce, run the following commands:

$ sudo yum install -y epel-release
$ sudo yum groupinstall -y "Xfce"
$ sudo reboot

Then create the file.Xclients in the user directory with which the connection will be made:

$ echo "xfce4-session" > ~/.Xclients
$ chmod a+x ~/.Xclients

Now you can connect to the server using Remote Desktop Connection. This is what Xfce looks like:

Screenshot №1. Xfce

Xfce Removal

To remove Xfce from your CentOS 7, run the following commands:

$ sudo yum groupremove -y "Xfce"
$ sudo yum remove -y libxfce4*

Install MATE Desktop Environment

To install MATE, run the following commands:

$ sudo yum install -y epel-release
$ sudo yum groupinstall -y "MATE Desktop"
$ sudo reboot

Then create the file.Xclients in the directory of the user you are connecting to:

$ echo "mate-session" > ~/.Xclients
$ chmod a+x ~/.Xclients

Now you can connect to the server using Remote Desktop Connection. This is what MATE looks like:

Screenshot №2. MATE

Removing the MATE

To remove MATE from CentOS 7, run the following commands:

$ sudo yum groupremove -y "MATE Desktop"
$ sudo yum autoremove -y

Install GNOME Desktop Environment

Now try installing GNOME 3. To do this, we need to install the GNOME Desktop package group, which will install all the packages necessary for installation with a graphical interface:

$ sudo yum groupinstall "GNOME DESKTOP" -y

This could take some time. On the minimum configuration of the CentOS 7 distribution, about 1000 packages will be installed.

Launch the graphical interface

Although we installed the GNOME Desktop package group, the GUI will not load by default upon reboot. We can verify this by running:

$ systemctl get-default

Conclusions:

multi-user.target

If the default value is multi-user.target, this means that the GUI will not load. Change the default value to graphical.target. To do this, run the following commands:

$ sudo systemctl set-default graphical.target

Conclusions:

Removed symlink /etc/systemd/system/default.target.

Created symlink from /etc/systemd/system/default.target to usr / lib / systemd / system / graphical.target.

After that, run the following command to immediately switch to the graphical interface:

$ sudo systemctl isolate graphical.target

Now you can connect via xRDP to your CentOS 7 using GNOME.

This is what GNOME 3 looks like when you first connect after installation. Just follow the initial setup steps to complete the setup:

Screenshot №3. GNOME 3

Note: If you used Xfce or MATE Desktop to connect to CentOS 7 before installing the GNOME Desktop graphical shell, run the following command:

$ sudo rm -f ~/.Xclients

Removing of GNOME

To remove GNOME from your CentOS 7, run the following commands:

$ sudo yum groupremove -y "GNOME Desktop"
$ sudo yum autoremove -y

Connect to a computer using Remote Desktop Connection

After installing xRDP and the desktop environment, you can connect from the local computer to the remote.

Connection from Windows

To connect to the server from Microsoft Windows, simply find and launch the Remote Desktop Connection application (mstsc.exe) and enter your hostname or IP:

Screenshot №4. Remote Desktop Connection

If this is your first time connecting, you will receive several security warnings. Assuming this is your server and it is secure, just accept these warnings:

Screenshot №5. Security warnings