Hostwinds Tutorials

Search results for:


Table of Contents


Prerequisites
Step 1: Install an RDP Server on Your Linux Machine
Step 2: Configure xrdp for Your Linux Desktop Environment
Step 3: Allow RDP Traffic Through the Linux Firewall
Step 4: Connect from Windows to the Linux Machine
Troubleshooting Common Issues
You're Connected!

How to Remote Access Linux with Windows

Tags: Cloud Servers,  Windows 

Prerequisites
Step 1: Install an RDP Server on Your Linux Machine
Step 2: Configure xrdp for Your Linux Desktop Environment
Step 3: Allow RDP Traffic Through the Linux Firewall
Step 4: Connect from Windows to the Linux Machine
Troubleshooting Common Issues
You're Connected!

Remote Desktop Protocol (RDP)  allows you to connect to and manage a remote computer as if you were sitting in front of it. While RDP is commonly associated with Windows systems, you can also use it to connect to Linux machines.

In this tutorial, we'll walk you through the process of setting up and using RDP to access a Linux machine from Windows.

Prerequisites

Before we begin, let's confirm the following:

  1. Linux Machine: A Linux system (e.g., Ubuntu, CentOS, Fedora) that you want to connect to.
  2. Windows Machine: A computer running Windows with RDP client software (e.g., Remote Desktop Connection).
  3. Network Configuration: Both systems are on the same network, or the Linux machine is accessible via public IP/hostname.
  4. Permissions: Admin or sudo access to the Linux machine. If you need help with this, check out  our tutorial on How to Create Sudo User

Step 1: Install an RDP Server on Your Linux Machine

Windows uses the RDP protocol by default, so you'll need to install an RDP server on your Linux machine. A popular option is xrdp.

  1. Open a Terminal on the Linux Machine
  2. Install xrdp
  • On Ubuntu or Debian-based systems, run:
sudo apt update
sudo apt install xrdp -y
  • On CentOS or Fedora, use::

sudo yum install epel-release -y
sudo yum install xrdp -y

3. Start and Enable xrdp

  • Start the xrdp service:

sudo systemctl start xrdp
  • Enable it to start on boot:

sudo systemctl enable xrdp

4. Check the Status

  • Verify that the service is running:

sudo systemctl status xrdp

Step 2: Configure xrdp for Your Linux Desktop Environment

Different desktop environments (e.g., GNOME, KDE, XFCE) require specific configurations. Here's a common approach:

1.Check Installed Desktop Environment:

  • If unsure, use the following command to determine your desktop environment:

echo $XDG_CURRENT_DESKTOP

2. Configure xrdp to Use the Desktop Environment

  • Edit the xrdp.ini file:
sudo nano /etc/xrdp/xrdp.ini
  • Ensure it references your preferred desktop session. For example:

exec=startxfce4
  • Replace startxfce4 with the command for your desktop environment (e.g., startgnome or startkde).

3. Restart the xrdp Service:

sudo systemctl restart xrdp

Step 3: Allow RDP Traffic Through the Linux Firewall

Ensure that your Linux machine's firewall allows RDP traffic (port 3389 by default).

1.Open the RDP Port

  • For ufw (Ubuntu Firewall):
sudo ufw allow 3389
  • For firewalld:
sudo firewall-cmd --permanent --add-port=3389/tcp
sudo firewall-cmd --reload

2. Verify the Open Port:

sudo netstat -tulpn | grep 3389

For more information on Linux ports, check out 5 Ways to Check Open on Linux.

Step 4: Connect from Windows to the Linux Machine

Now that the Linux machine is ready, it's time to connect from Windows.

  1. Open Remote Desktop Connection:
    • Press Win + R to open the Run dialog, type mstsc, and hit Enter.
  2. Enter the Linux Machine's IP Address:
    • In the Remote Desktop Connection window, enter the Linux machine's IP address or hostname.
  3. Authenticate:
    • You'll be prompted to log in. Use your Linux username and password.
  4. Start the Session:
    • Click "Connect." If everything is set up correctly, you'll see your Linux desktop on the screen.

Troubleshooting Common Issues

If your Linux desktop isn't loading through RDP, it may be due to a variety of factors, but a few simple checks can help you quickly identify and resolve the problem. Here are some of the more common issues you might come across:

  • Black Screen or Session Fails to Load:
    • Ensure the correct desktop environment is configured for xrdp.
    • Check that your Linux machine has sufficient resources (RAM, CPU) to handle an RDP session.
  • Firewall or Network Issues:
    • Verify that port 3389 is open and the machine is accessible from the Windows system.
  • Credential Errors:
    • Double-check the username and password you're using. Make sure the user account has permission to access the desktop environment.

You're Connected!

Using RDP to connect from Windows to a Linux machine is a convenient way to manage your systems. Now you can seamlessly switch between operating systems, leveraging the best of both worlds.

If you have any questions or run into issues, feel free to ask for help or consult the documentation for xrdp and your Linux distribution. Happy remote accessing!

Written by Karlito Bonnevie  /  April 27, 2022