Many users are working on multiple operating systems on numerous machines, so carrying all these machines all the time is not feasible. Remote Desktop is used to connect different operating systems like Debian from remote locations. It enables the user to connect to the network and access all your resources from a single machine across the globe.
How to Connect Debian to the Remote Desktop
To connect the Debian machine on a remote desktop, log in to the Debian machine and install the desktop environment on it. The desktop environment is required to install the X Remote Desktop Protocol or “xrdp” on Debian 12. Once the “xrdp” is installed, simply configure it and add it as the user in the Debian machine with the firewall settings attached to it. After that, simply open the RDP from the client machine and connect to the Debian machine.
Step 1: Update apt Packages
Start the process by heading into the terminal on Debian and execute the following command with root privileges:
sudo apt update && sudo apt upgrade
The above command is used to update and upgrade the apt packages to get the latest application from the package manager:
Step 2: Install Desktop Environment
The desktop environment is required to install the remote desktop on the host machine and connect to the RDP using it. Now, use the following command to get the xfce4 and xfce4-goodies desktop environment on the Debian machine:
sudo apt install xfce4 xfce4-goodies -y
After installing the desktop environment, reboot the system to implement the required changes for the xfce application:
sudo reboot
Step 3: Install X Remote Desktop Protocol
After that, open the xfce Terminal on the Debian 12 machine to configure the remote connection:
Now, install the xrdp or X Remote Desktop Protocol on the host machine so it can be connected to the client remotely:
sudo apt install xrdp -y
Check the status of the xrdp using the following command to confirm its successful installation on the system:
sudo systemctl status xrdp
The following screenshot displays that the xrdp is “Active (running)” that confirms the successful installation:
Step 4: Configure X Remote Desktop Protocol
Run the nano command to open the “etc/xrdp/startwm.sh” file to change the configuration of the remote desktop:
sudo nano /etc/xrdp/startwm.sh
Locate the following lines from the file and add the “#” character before both of these lines as displayed in the next screenshot attached:
test -x /etc/X11/Xsession && exec /etc/X11/Xsession
exec /bin/sh /etc/X11/Xsession
Also, add the following line in the file to establish the connection from the client’s remote desktop:
startxfce4
Adding the above line in the file instructs the xrdp to initiate or start the xfce desktop environment at the time of connecting to the Remote Desktop Protocol:
After configuring the file, simply save the file using the “Ctrl + s” and head back to the terminal using the “Ctrl + x” from the keyboard.
On the terminal, use the following command to restart the xrdp services:
sudo systemctl restart xrdp
After that, simply confirm that the service is working by checking its status using the following command:
sudo systemctl status xrdp
The following screenshot displays that the xrdp is actively running after the execution of the above command:
Step 5: Get the Port to Connect Remotely
Now, you need to check the port number that allows the remote connection from the client system if you already don’t know that. Use the following command to open the “/etc/xrdp/xrdp.ini” file to check the port number as the entry point:
sudo nano /etc/xrdp/xrdp.ini
Executing the above command opens the file containing the port number “3389” and you can edit the port number if it is busy somewhere else. However, we will go on with the same port number as 3389 is the default port to connect through the RDP:
Now, simply enable the xrdp service by using the following command:
systemctl enable xrdp
Running this command enables the xrdp services as displayed in the following screenshot:
Step 6: Update Firewall Settings
After enabling the xrdp services, simply make the network secure by adding the Uncomplicated Firewall (UFW). To do so, execute the “ufw status” command on the xfce terminal to check the status of the firewall:
sudo ufw status
After that, add the xrdp user to the ssl-cert group to get access to the firewall using the following command:
sudo adduser xrdp ssl-cert
Now, add the firewall rule that enables the 3389 port which is the RDP port to connect to the machine remotely:
sudo ufw allow 3389
Finally, confirm whether the rule has been added to the UFW by checking its status once again:
sudo ufw status
The rule has been added to the uncomplicated firewall as displayed in the following snippet:
At the end, simply enable the firewall services using the “ufw enable” command:
sudo ufw enable
Step 7: Get the IP Address of Debian 12
To connect to Debian using the remote desktop, we need to know the IP address of the Debian machine. To get the IP address of the machine, simply use the command mentioned below:
ip a
The snippet below shows the results of the above command containing the IP address with the broadcast address. Now, simply copy the IP address and store it, so it can be used to connect from other machine:
Step 8: Connect to Debian Using RDP
Now, get back to the Windows machine and search for the Remote Desktop Connection file and open it:
Click on the “Show Options” from the Remote Desktop Connection tab as displayed below:
On the General tab of the Remote Desktop Connection, type the IP address with the port number in the Computer section. The syntax for this is “IP-ADDRESS:PORT” and the user name of the host machine is mentioned in the User name text box. After adding these credentials, simply click on the “Connect” button and you can also save it to use it in the future:
To confirm the connection, simply click on the “Yes” button on the Verify window:
To use the Debian machine from RDP, you need to provide the credentials for the user of the Debian machine. After that, simply click on the “OK” button to log in to the Debian user and get access to its resources remotely:
Clicking on the OK button connects to the Debian user from the Remote Desktop Connection on Windows:
Bonus: Uninstall XRDP From Debian
You can also uninstall the xrdp from Debian 12 if you don’t need it on your system anymore. To do that, simply use the purge command to remove all the resources and configurations attached to the xrdp:
sudo apt purge xrdp -y
That’s all about how to use the Debian 12 on Remote Desktop Connection from Windows.
Conclusion
To use the Debian machine on the Remote Desktop, open the terminal to Debian 12 to install the xfce desktop environment. After that, open its terminal to install the xrdp on the Debian machine and configure it to start the xfce environment at the time of remote connection. Also, configure the Uncomplicated Firewall by adding the xrdp user to it and add the port number as the firewall rule. After that, simply open the Remote Desktop Connection from the client machine and use the IP address of the Debian to establish the connection.