Introduction
Xrdp is a free tool that lets you connect to a Linux server from Windows machines using the RDP protocol.
This tutorial covers how to set up xrdp on RedHat-based distributions, including CentOS 7, AlmaLinux 8, and AlmaLinux 9.
Steps to Install XRDP
1. Import GPG Key Repository (For AlmaLinux 8 Only)
This step is only necessary for AlmaLinux 8. Skip it if you are using CentOS 7 or AlmaLinux 9.
To add the GPG key repository on AlmaLinux 8, run:
rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux
2. Update Packages
- Before installing xrdp, ensure your system packages are up-to-date by running:
yum update
3. Install the EPEL Repository
- The EPEL repository provides access to extra packages. Enable it with:
yum install epel-release
4. Install Xrdp
- To install xrdp and TigerVNC server, run:
yum -y install xrdp tigervnc-server
5. Enable Xrdp
- Enable xrdp to start on boot with:
systemctl enable xrdp
- Then restart xrdp to apply the changes:
systemctl restart xrdp
6. Install GUI
- A graphical interface is needed to log into the server via xrdp. Here, we'll install Xfce:
yum groups -y install "Xfce"
- On CentOS 7 and AlmaLinux 9, create the Xclients file (this step is not required for AlmaLinux 8):
vi ~/.Xclients
- Add the following content:
#!/bin/bash
XFCE="$(which xfce4-session 2>/dev/null)"
exec "$XFCE"
chmod +x .Xclients
- Restart xrdp to apply changes:
service xrdp restart
7. Enable RDP Port
iptables -I INPUT -p tcp -m tcp --dport 3389 -j ACCEPT
Then save the changes:
On CentOS 7:
service iptables save
iptables-save
- If using firewalld, open port 3389 with:
firewall-cmd --add-port=3389/tcp --permanent
firewall-cmd --reload
8. Check Xrdp
- Verify that xrdp is running with:
systemctl status xrdp.service
Log in from a Windows Computer
To test xrdp, connect to your server from a Windows computer using the Remote Desktop application. Enter:
Computer: Your_server_IP
Username: root
Click "Connect" and enter your server's password on the xrdp login screen.
- If the credentials are correct, you will access the server's GUI. The first time you connect on CentOS 7, you may be prompted to select a setup; choose the default configuration.
Log in from Linux
- To connect from a Linux machine, use an RDP client like
rdesktop
:
rdesktop -u root -p PASSWORD -g 1024x768 YOUR_SERVER_IP
- Replace
PASSWORD
and YOUR_SERVER_IP
with your actual credentials. You can change the screen resolution by adjusting the -g 1024x768
parameter.
Note: The first connection might take a bit longer to load the desktop environment, which is normal.