Test your skills on our all Hosting services and get 15% off!

Use code at checkout:

Skills
30.10.2024

How to Connect to Ubuntu from Windows Using RDP

Remote Desktop Protocol (RDP) allows users to access and control a remote computer over a network as if they were sitting directly in front of it. While RDP is natively supported by Windows, Ubuntu doesn’t come with built-in RDP support. However, you can easily set up an RDP server on your Ubuntu machine and connect to it from a Windows computer using the Remote Desktop client.

In this article, we’ll explain how to set up an RDP connection between Windows and Ubuntu step-by-step.


Step 1: Install an RDP Server on Ubuntu

Ubuntu doesn’t come with an RDP server by default, so you need to install one. One of the most commonly used RDP servers for Ubuntu is xrdp.

To install xrdp:

  1. Open the Terminal on your Ubuntu machine (press Ctrl + Alt + T).
  2. Update the package lists:
    sudo apt update
  3. Install xrdp:
    sudo apt install xrdp
  4. Once installed, start the xrdp service:
    sudo systemctl enable xrdp sudo systemctl start xrdp
  5. To check if xrdp is running, use this command:
    sudo systemctl status xrdp

Now that xrdp is installed and running, Ubuntu is ready to accept remote desktop connections.


Step 2: Configure the Firewall on Ubuntu

To allow RDP connections through Ubuntu’s firewall, you need to open port 3389, which is the default port used by RDP.

To allow RDP through the firewall:

  1. If UFW (Uncomplicated Firewall) is enabled on your Ubuntu machine, allow the RDP port by running:
    sudo ufw allow 3389/tcp
  2. If the firewall is disabled, you can enable it:
    sudo ufw enable

After completing these steps, the Ubuntu machine should be ready to accept incoming RDP connections.


Step 3: Connect to Ubuntu from Windows Using RDP

Once the RDP server is set up on Ubuntu, you can use Windows’ built-in Remote Desktop Connection tool to connect.

To connect to Ubuntu from Windows:

  1. On your Windows computer, press Windows + R to open the Run dialog box.
  2. Type mstsc and press Enter. This will open the Remote Desktop Connection tool.
  3. In the Remote Desktop Connection window, type the IP address of your Ubuntu machine. To find your Ubuntu machine’s IP address, you can run the following command in the terminal:
    hostname -I
  4. Click Connect.
  5. A login screen will appear. Enter your Ubuntu username and password and click OK.

You should now be connected to your Ubuntu desktop from your Windows computer, and you can control it as if you were using it locally.


Step 4: Troubleshooting Common Issues

If you encounter issues while connecting to Ubuntu using RDP, here are some common problems and their solutions:

1. Black Screen After Login

If you successfully connect but see only a black screen, this is likely due to a display issue with the xrdp session. To fix it, you can set your Ubuntu desktop environment to Xfce, which is known to work well with xrdp.

Install Xfce:
sudo apt install xfce4

Next, you’ll need to tell xrdp to use Xfce:

  1. Edit the xrdp configuration file:
    echo xfce4-session >~/.xsession
  2. Restart xrdp:
    sudo systemctl restart xrdp

Now, try connecting again, and the black screen issue should be resolved.

2. Firewall Blocking Connection

If you can’t connect to the Ubuntu machine, make sure the firewall is correctly configured to allow connections on port 3389.

  • Check the firewall status:
    sudo ufw status

If you don’t see the rule for port 3389, you may need to add it again using:

sudo ufw allow 3389/tcp

3. Slow Connection

If you experience a slow connection, try reducing the display quality when connecting. In the Remote Desktop Connection window, go to Show Options > Display and lower the display quality.


Step 5: Enhance Security for RDP Connections

To improve security when using RDP, follow these best practices:

1. Change the RDP Port

By default, RDP uses port 3389, which is widely known. To reduce the risk of unauthorized access, you can change the RDP port to a custom port.

To change the xrdp port:

  1. Open the xrdp.ini file:
    sudo nano /etc/xrdp/xrdp.ini
  2. Find the line that says port=3389 and change it to another port number (e.g., 3390).
  3. Save and exit the file, then restart xrdp:
    sudo systemctl restart xrdp
  4. You will also need to update your firewall to allow the new port.

2. Use a VPN

Whenever possible, connect to the Ubuntu machine via a VPN (Virtual Private Network) before using RDP. This adds an additional layer of encryption and security.

3. Use Strong Passwords

Ensure that the Ubuntu user account has a strong password to prevent brute-force attacks. Consider implementing two-factor authentication (2FA) for added protection.


Conclusion

Setting up an RDP connection between Ubuntu and Windows is a straightforward process with the help of the xrdp server. By following the steps in this guide, you can enable remote access to your Ubuntu desktop and control it from a Windows machine. Just remember to configure the necessary firewall settings and troubleshoot any connection issues. Additionally, improving security with options like changing the default RDP port and using VPNs will help ensure that your remote connection remains safe and reliable.

Test your skills on our all Hosting services and get 15% off!

Use code at checkout:

Skills