Guide to Set Up XRDP for Remote Desktop Access on Kali Linux

0 Comments

Remote Desktop Protocol (RDP) allows you to connect to your Kali Linux machine through a graphical interface from another device. This guide walks you through installing, and configuring an open-source implementation of Microsoft’s RDP, so you can access your Kali system remotely.

Whether you’re managing a lab environment, running Kali on a virtual machine, or just prefer GUI access over SSH, this step-by-step tutorial will help you get started quickly.


Step 1: Install XRDP on Kali Linux

1.1. Update the System

Before starting the installation, ensure your Kali Linux system is up to date:

sudo apt update && sudo apt upgrade -y

1.2. Install XRDP

Next, install XRDP, which will allow you to use RDP to connect to your Kali Linux machine:

sudo apt install xrdp -y

1.3. Install a Desktop Environment (Optional)

XRDP requires a desktop environment to display the graphical interface. We will install Xfce, a lightweight and fast desktop environment:

sudo apt install xfce4 xfce4-goodies -y

1.4. Set Xfce as the Default Session

To make Xfce the default session when connecting via RDP, create or modify the ~/.xsession file:

echo "startxfce4" > ~/.xsession

Step 2: Configure XRDP

2.1. Start and Enable XRDP Service

Start the XRDP service and enable it to start automatically at boot:

sudo systemctl start xrdp sudo systemctl enable xrdp

2.2. Verify XRDP Status

Check if XRDP is running correctly:

sudo systemctl status xrdp

You should see output indicating that XRDP is active and running:

● xrdp.service - xrdp daemon Loaded: loaded (/usr/lib/systemd/system/xrdp.service; enabled; preset: disabled) Active: active (running)

2.3. Configure the xrdp.ini File (Optional)

If you need to adjust the configuration for session types, ports, or authentication methods, follow these steps:

  1. Rename the xrdp.ini.original file: If the xrdp.ini file is missing, you may have a backup file named xrdp.ini.original. Rename it to xrdp.ini:
sudo mv /etc/xrdp/xrdp.ini.original /etc/xrdp/xrdp.ini
  1. Edit the xrdp.ini file: Open the xrdp.ini file in a text editor:
sudo nano /etc/xrdp/xrdp.ini

Modify the configuration as needed. Here's an example of a basic configuration:

[Globals] ListenAddress=0.0.0.0 ListenPort=3389 MaxSessions=50 LogLevel=DEBUG LogFile=/var/log/xrdp.log [Xorg] name=Xorg lib=libxup.so username=ask password=ask ip=127.0.0.1 port=-1 code=20 [Xvnc] name=Xvnc lib=libvnc.so username=ask password=ask ip=127.0.0.1 port=-1 xserverbpp=24 delay_ms=2000
  1. Save and exit the editor (Ctrl + X, then press Y to confirm changes).
  2. Restart XRDP to apply the configuration:
sudo systemctl restart xrdp

Step 3: Configure the Firewall

If you’re using UFW (Uncomplicated Firewall), you need to allow RDP traffic on port 3389.

3.1. Allow RDP Port Through UFW

To allow incoming RDP connections, run the following command:

sudo ufw allow 3389/tcp

3.2. Verify UFW Status

Ensure that the rule has been added by checking the firewall status:

sudo ufw status

You should see an entry like this:

3389 ALLOW Anywhere

3.3. Reload UFW (Optional)

If necessary, reload the firewall to apply the changes:

sudo ufw reload

Step 4: Connect to Kali Linux via RDP

Now that XRDP is set up and the firewall is configured, you can connect to your Kali Linux machine using any RDP client (e.g., Windows Remote Desktop, Remmina, or FreeRDP).

  1. Open your RDP client and enter the IP address or hostname of your Kali Linux machine.
  2. Log in using your Kali username and password.

Conclusion

You have now successfully set up XRDP for remote desktop access on your Kali Linux machine. You can connect via RDP using any compatible client, and the firewall is configured to allow RDP traffic. If you run into any issues, refer to the troubleshooting section to resolve common problems.


AI assistance was used for grammar and readability.