How to Use RDP on Linux Command Line

How to Use RDP on Linux Command Line? Step-by-Step Guide

To access RDP on the Linux command line, you can use such programs as rdesktop, xfreerdp, or Remmina (CLI mode). These are programs that allow you to connect to a windows machine remotely via the Remote Desktop Protocol, but without a graphical interface. As an example, when using xfreerdp, one can type in a command like xfreerdp /v:IP_ADDRESS /u:USERNAME /p:PASSWORD to connect to a remote machine, giving its IP address, username, and password. This is convenient when the server, script or lightweight Linux system does not have a full GUI client.

Step-by-Step Guide: How to Use RDP on Linux Command Line?

Step 1: Understanding RDP and Why Use it on Linux

RDP is a proprietary protocol developed by Microsoft that allows users to connect to a Windows machine remotely. While there are other protocols like Secure Shell (SSH) and Virtual Network Computing (VNC), RDP is often favored for its ability to provide a seamless graphical interface.

Using RDP from Linux can be beneficial for several reasons:

  • Access to Windows-Only Software: You can use RDP to run software that is only available on Windows.
  • Graphical Interface: Unlike SSH, which provides command-line access, RDP offers a graphical interface, making it easier to use applications that rely on visual elements.
  • Remote Management: Linux users can manage Windows servers or desktops without needing a separate Windows machine.

Step 2: Setting Up RDP on Linux

To use RDP on Linux, you’ll need to install an RDP client. There are several popular options to choose from, but the most commonly used command-line tools include:

  • xfreerdp: A free implementation of the RDP protocol for Unix-based systems.
  • rdesktop: An older, but still popular, command-line RDP client for Linux.
  • remmina: A remote desktop client that supports multiple protocols, including RDP, VNC, and SSH, but it also has a CLI option.

Installing xfreerdp:

  1. Open your terminal and update your package repository:
    bash   Copy code
    sudo apt update
  2. Install xfreerdp using the following command:
    bash   Copy code
    sudo apt install freerdp2-x11 -y
  3. Verify the installation by checking the version:
    bash   Copy code
    xfreerdp --version

Installing rdesktop:

  1. Update your package repository:
    bash   Copy code
    sudo apt update
  2. Install rdesktop with:
    bash   Copy code
    sudo apt install rdesktop -y
  3. Verify the installation:
    bash   Copy code
    rdesktop --version

Step 3: Connecting to a Remote Machine Using xfreerdp

xfreerdp is the recommended RDP client due to its support for newer RDP features and better performance. To connect to a remote Windows machine using xfreerdp, use the following syntax:

bash   Copy code
xfreerdp /v:<IP-ADDRESS> /u:<USERNAME> /p:<PASSWORD>
  • /v specifies the target IP address or hostname.
  • /u specifies the username to log in with.
  • /p specifies the password. If you prefer not to include the password in the command for security reasons, you can omit this option and xfreerdp will prompt you for the password.

For example, to connect to a Windows machine at IP 192.168.1.100 using the username admin:

bash   Copy code
xfreerdp /v:192.168.1.100 /u:admin

xfreerdp will prompt you for the password. If the credentials are correct, the remote desktop session will start.

Additional xfreerdp Options

xfreerdp comes with many useful options for customizing your remote desktop session:

  • /size:WIDTHxHEIGHT: Specifies the size of the RDP window. For example, to open a 1280×720 window:
    bash   Copy code
    xfreerdp /v:192.168.1.100 /u:admin /size:1280x720
  • /bpp:COLOR_DEPTH: Sets the color depth (bits per pixel). Lowering the color depth can improve performance. For example, to set the color depth to 16:
    bash Copy code
    xfreerdp /v:192.168.1.100 /u:admin /bpp:16
  • /clipboard: Enables clipboard sharing between the local and remote machines:
    bash   Copy code
    xfreerdp /v:192.168.1.100 /u:admin /clipboard
  • /drive:SHARE_NAME,LOCAL_PATH: Shares a local directory with the remote machine. For example, to share your Documents folder:
    bash   Copy code
    xfreerdp /v:192.168.1.100 /u:admin /drive:shared,/home/user/Documents

Step 4: Using rdesktop to Connect to a Remote Machine

rdesktop is another option for command-line RDP connections. Although it’s less feature-rich than xfreerdp, it’s simpler and may be sufficient for basic use.

To connect using rdesktop, use the following syntax:

bash   Copy code
rdesktop <IP-ADDRESS> -u <USERNAME> -p <PASSWORD>

For example:

bash   Copy code
rdesktop 192.168.1.100 -u admin -p password

Additional rdesktop Options
Some useful options for rdesktop include:

  • -g WIDTHxHEIGHT: Specifies the geometry of the RDP window. For example:
    bash   Copy code
    rdesktop 192.168.1.100 -u admin -p password -g 1280x720
  • -a COLOR_DEPTH: Specifies the color depth:
    bash   Copy code
    rdesktop 192.168.1.100 -u admin -p password -a 16

Step 5: Troubleshooting Common Issues

If you encounter issues while connecting to a remote machine using RDP, consider the following troubleshooting tips:

  • Firewall Settings: Ensure that port 3389 (the default RDP port) is open on the remote machine. You may need to modify firewall settings to allow RDP connections.
  • RDP Services: Make sure that the Remote Desktop service is enabled and running on the Windows machine.
  • Network Connectivity: Verify that the Linux and Windows machines are on the same network or have proper routing rules if connecting over the internet.
  • RDP Settings: Check if the remote Windows machine allows RDP connections. Go to Control Panel > System > Remote Settings and ensure that “Allow Remote Assistance” is enabled.

Conclusion

Using RDP from the Linux command line is a powerful way to access and manage remote Windows machines. Whether you choose xfreerdp for its advanced features or rdesktop for its simplicity, knowing how to use these tools can greatly enhance your productivity and flexibility. With the right configuration and command options, you can create a seamless remote desktop experience that meets your specific needs.

By following this guide, you should be able to successfully connect to a Windows machine using RDP from your Linux command line. Experiment with different options and configurations to find the setup that works best for you.

Scroll to Top