The simplest and most commonly used method to connect to a Linux graphical interface from a Windows PC is with RDP via xrdp. This setup is widely preferred due to its ease of use, native Windows compatibility, and reliable performance.
-
Ease of Use: xrdp is straightforward to configure on Linux, and Windows has a built-in Remote Desktop Connection tool, eliminating the need for additional software on the Windows PC.
-
Widespread Compatibility: The xrdp tool utilizes the RDP protocol, which is native to Windows, ensuring optimized compatibility and smooth integration.
-
Reliable Performance: RDP delivers smooth, fast performance in most cases, even on average network connections.
To connect to the Linux graphical interface from a Windows PC, you first need to install and configure xrdp on the Linux VM. Follow these steps:
Run the following commands to update your system and install xrdp:
sudo apt update
sudo apt install xrdpStart the xrdp service and configure it to start automatically at boot:
sudo systemctl enable xrdp
sudo systemctl start xrdpRun the following command to allow traffic on port 3389 for RDP connections:
sudo iptables -A INPUT -p tcp --dport 3389 -j ACCEPTTo verify that the rule was successfully applied, list the current iptables rules:
sudo iptables -Lsudo ss -tuln | grep 3389Follow these steps to connect to your Linux VM's graphical interface using the Remote Desktop Connection tool in Windows:
- Press Win + R to open the Run dialog box.
- Type
mstscand press Enter. This will launch the Remote Desktop Connection application. - In the Remote Desktop Connection window, enter the IP address of your Linux VM in the Computer field.
- Click Connect.
- A login window will appear. Enter your username and password for the Linux VM.
- If the connection is successful, the graphical interface of your Linux VM will appear in a new window on your Windows PC.
- If you encounter issues like the RDP window disappearing after entering the password, or a black screen after connecting, these are often caused by misconfigurations between xrdp and the desktop environment on your Linux VM. Follow the steps below to resolve these problems:
-
Check and Update the xrdp Startup File , Open
startwm.sh:sudo nano /etc/xrdp/startwm.sh
-
Modify the content of the file to match this content : Check out the
startwm.shfile -
Restart the xrdp Service
sudo systemctl restart xrdp- Verify or Create the .xsession File in Your User Directory and Make sure the file has the correct execution permissions
echo "startxfce4" > ~/.xsession
chmod +x ~/.xsession- Restart the VM and Reconnect
sudo reboot- If the Problem Persists , Ensure that Xfce is properly installed
sudo apt install --reinstall xfce4You can now use your Linux environment remotely with full GUI access!