How to Install and Configure XRDP in Kali Linux for Remote Desktop Access (Step-by-Step Guide)
How to Install and Configure XRDP in Kali Linux (Step-by-Step Guide)
Remote Desktop access is very useful when you want to control your Kali Linux system from another computer without sitting in front of it. XRDP allows you to connect to a Linux desktop using Microsoft Remote Desktop Protocol (RDP), which is commonly used in Windows systems.
This guide explains how to install, configure, and fix common XRDP issues in Kali Linux so you can access your Kali desktop remotely.
What is XRDP?
XRDP is an open-source implementation of the Remote Desktop Protocol (RDP) that allows users to connect to a Linux machine remotely using an RDP client.
Advantages
Access Kali Linux remotely from Windows
Useful for remote labs and server management
Allows graphical desktop access
Lightweight and easy to configure
Default XRDP Port
XRDP runs on the following port:
3389
Step 1: Update Your Kali Linux System
Before installing XRDP, it is recommended to update your system packages.
Run the following command:
sudo apt update && sudo apt upgrade -y
This ensures that all packages and dependencies are up to date.
Step 2: Install XRDP
Install the XRDP package using the following command:
sudo apt install xrdp -y
Once installed, the configuration files will be located in:
/etc/xrdp/
Important configuration files include:
| File | Description |
|---|---|
| xrdp.ini | Main XRDP configuration file |
| sesman.ini | Session manager configuration |
| startwm.sh | Desktop session startup script |
Step 3: Add XRDP User to SSL Certificate Group
XRDP uses SSL certificates to encrypt connections.
Add the XRDP user to the ssl-cert group:
sudo adduser xrdp ssl-cert
Step 4: Enable and Start XRDP Service
Enable XRDP so it starts automatically when the system boots.
sudo systemctl enable xrdp
Start the XRDP service:
sudo systemctl start xrdp
Check the service status:
sudo systemctl status xrdp
You should see:
Active: active (running)
Step 5: Verify XRDP is Listening on Port 3389
Check whether XRDP is running on the correct port.
sudo ss -tulpn | grep 3389
Example output:
tcp LISTEN 0 2 *:3389 *:* users:(("xrdp"))
This means the XRDP service is active and ready for remote connections.
Step 6: Find Your Kali Linux IP Address
To connect remotely, you need the IP address of your Kali machine.
Run:
ip a
Look for the IP address under your network interface (usually eth0 or wlan0).
Example:
inet 10.212.16.28/24
Your remote connection address will be:
10.212.16.28
Step 7: Fix Kali XRDP Session Issue
Sometimes XRDP fails to load the desktop environment in Kali Linux.
Create a session file to ensure the XFCE desktop starts properly.
Run:
echo xfce4-session > ~/.xsession
Step 8: Configure XRDP Startup Script
Edit the XRDP window manager startup script.
sudo nano /etc/xrdp/startwm.sh
Add the following lines at the top of the file:
unset DBUS_SESSION_BUS_ADDRESS
unset XDG_RUNTIME_DIR
Scroll to the bottom of the file and replace the last lines with:
startxfce4
Save and exit:
CTRL + X
Y
ENTER
This ensures the XFCE desktop environment loads correctly during remote login.
Step 9: Restart XRDP Service
Restart the XRDP service to apply changes.
sudo systemctl restart xrdp
Step 10: Connect to Kali Linux from Windows
On your Windows machine:
Press Win + R
Type:
mstsc
Enter the Kali Linux IP address:
10.212.16.28
Click Connect
Step 11: XRDP Login Screen
When the XRDP login window appears, enter:
Session: Xorg
Username: kali (or your username)
Password: your Kali password
After logging in, you will see your Kali Linux desktop environment remotely.
Summary of Commands
sudo apt update
sudo apt install xrdp -y
sudo adduser xrdp ssl-cert
sudo systemctl enable xrdp
sudo systemctl start xrdp
ip a
echo xfce4-session > ~/.xsession
sudo nano /etc/xrdp/startwm.sh
sudo systemctl restart xrdp
Conclusion
XRDP provides a simple and effective way to remotely access Kali Linux using the Remote Desktop Protocol. By following this guide, you can install XRDP, configure the desktop session, and securely connect to your Kali machine from another computer.
This setup is especially useful for cybersecurity labs, remote penetration testing environments, and managing Kali Linux servers.
