How to Set Up a Remote Desktop with XRDP
How to Set Up a Remote Desktop with XRDP
In today’s increasingly remote work environment, accessing your desktop from anywhere is a valuable asset. XRDP is a free and open-source implementation of the Microsoft Remote Desktop Protocol (RDP) that allows you to connect to your Linux desktop from a Windows machine or another Linux system. This article will guide you through the steps to set up a remote desktop using XRDP on your Linux machine, ensuring that you can access your desktop easily and securely.
Prerequisites
Before you start, ensure you have the following:
- A Linux Machine: This guide will focus on Ubuntu, but XRDP can be installed on various Linux distributions.
- Root or Sudo Access: You’ll need administrative privileges to install software and configure settings.
- An Internet Connection: Ensure your Linux machine is connected to the internet.
Step 1: Update Your System
Start by updating your system to ensure all packages are current. Open a terminal and run:
sudo apt update && sudo apt upgrade -y
This command updates your package list and upgrades the installed packages to their latest versions.
Step 2: Install XRDP
To install XRDP, execute the following command in your terminal:
sudo apt install xrdp -y
This command installs the XRDP package. After installation, XRDP will start automatically. You can check its status with:
sudo systemctl status xrdp
If XRDP is running, you should see an output indicating that the service is active.
Step 3: Install a Desktop Environment
If you don’t have a desktop environment installed, XRDP requires one to function properly. For Ubuntu, you can install a lightweight desktop environment like XFCE:
sudo apt install xfce4 xfce4-goodies -y
Once the installation is complete, you need to configure XRDP to use XFCE. Open the configuration file:
echo “xfce4-session” > ~/.xsession
This command creates a new file in your home directory that tells XRDP to use XFCE as the desktop session.
Step 4: Configure XRDP
Now, configure XRDP to use the new session. Open the XRDP configuration file:
sudo nano /etc/xrdp/startwm.sh
Add the following lines just before the test command:
if [ -r /etc/X11/Xsession ]; then
. /etc/X11/Xsession
else
. /etc/X11/xinit/xinitrc
fi# Start XFCE
startxfce4
Save the file and exit the text editor (Ctrl + X, then Y to confirm, and Enter to exit).
Step 5: Allow RDP Through the Firewall
If you have a firewall enabled, you’ll need to allow RDP traffic. Use the following command to do this:
sudo ufw allow 3389/tcp
This command opens port 3389, which is the default port used by XRDP for RDP connections.
Step 6: Restart the XRDP Service
After making all the necessary configurations, restart the XRDP service to apply the changes:
sudo systemctl restart xrdp
Step 7: Connect to the XRDP Server
Now that XRDP is set up and running, you can connect to your Linux machine from a remote computer. On your Windows machine, follow these steps:
- Open Remote Desktop Connection: You can find this by searching for “Remote Desktop” in the start menu.
- Enter the IP Address: Type the IP address of your Linux machine and click on “Connect”.
- Log In: When prompted, enter your Linux username and password. You should now see your XFCE desktop.
Troubleshooting Common Issues
If you encounter issues when trying to connect, consider the following solutions:
- Check XRDP Status: Ensure that the XRDP service is running.
- Firewall Rules: Verify that the firewall is correctly configured to allow traffic on port 3389.
- Desktop Environment: Ensure that the desktop environment is correctly installed and configured in ~/.xsession.