Remote Desktop from Windows to Ubuntu Xrdp

This step-by-step article will detail how to establish a Remote Desktop connection from Windows to Ubuntu running in VirtualBox with pictures as a guide. The Ubuntu VM used in this guide has not been modified since it’s installation in VirtualBox, outlined in the post: Create Ubuntu VM in VirtualBox – Picture Guide.

Verify Windows Host / Ubuntu VM Connectivity

Before installing software on our Ubuntu host, a network interface needs to exist that will allow the host machine (Windows) to be able to communicate with the Guest machine (Linux VM).

Determine if you need to add an additional interface allowing connectivity between your Windows host and your Ubuntu guest VM.

  1. In Ubuntu, open a terminal and check your interfaces. A quick command to consistently check all interfaces in Linux is ip -4 a
  2. The example below shows that this Linux VM only has one interface, with an IP of 10.0.2.15.
VIrtualbox Linux VM one network interface without connectivity to windows host
This Ubuntu VM only has one network interface and therefore cant communicate with the windows host
  1. Now, check your ip address on your Windows machine using the command ipconfig. Chances are it is a 192.168.1.X IP as shown here
Ubuntu remote desktop connection configuration from windows network ip
The IP address of the Windows machine reveals that our Linux VM is not on the correct subnet

As you can see, the IP address of the Windows machine, 192.168.1.172, and the IP address of the Ubuntu VM, 10.0.2.15, are not on the same subnet. In order to establish a remote desktop connection between this Windows host and Ubuntu VM, we must add an additional interface to the Ubuntu VM that is on the same subnet as the Windows host.

We cannot simply change the IP address of the existing Ubuntu network interface. The existing interface is used to communicate with VirtualBox.


Create a Network Interface Enabling Windows/Ubuntu Connectivity

  1. In VirtualBox, shutdown the Ubuntu VM
  2. In VirtualBox with the VM selected, select Settings > Network
  3. By default, Adapter 1 may be the only interface running. Select the Adapter 2 tab.
  4. Check the box next to Enable Network Adapter.
  5. Select Bridged Adapter as the option for the Attached to: option. No other options needed, select Ok.
VirtualBox Network Interface Ubuntu Connection
VirtualBox Bridged Network Adapter connection for Ubuntu VM
  1. Start the Ubuntu VM back up
  2. Open a new terminal window and run ip -4 a again.
VirtualBox Ubuntu Network Interface same subnet as Windows Host Remote Desktop
The Ubuntu interface enp0s8 is on the same subnet as the Windows machine
  1. After adding the additional bridged adapter in the VM’s settings, this Linux host now has a network interfaced enp0s8 with an IP address of 192.168.1.194.
  2. Optionally, ping the IP address from a Windows command line for additional verification of network connectivity.
Ping VirtualBox Ubuntu network interface successful connection from windows host
Verification that we can ping the network interface on the Ubuntu host from Windows

Ping reveals that these two machines are able to communicate with one another. Its time to start configuring the Ubuntu machine for Remote Desktop connections from the Windows host.


Configure Ubuntu Firewall for Remote Desktop Connections

  1. Remote Desktop communicates over port 3389. So, add a firewall rule opening up port 3389.
    1. sudo ufw allow 3389/tcp
Configure Ubuntu firewall rule for windows remote desktop connection port 3389
Adding the Ubuntu firewall rule to enable remote desktop connections from Windows hosts

Install xRDP in Ubuntu

The installation of Xrdp on a Ubuntu VM will allow Remote Desktop from Windows machines.

  1. Install Xrdp. sudo apt-get install -y xrdp
ubuntu xrdp remote desktop windows connection
Sudo install xrdp on Ubuntu host- the Linux application that will accept Windows Remote Desktop connections
  1. How do you start xrdp in Ubuntu? It’s not with systemctl.
  2. Without additional configuration, Xrdp is managed via /etc/init.d/xrdp start, stop, restart, try-restart, status, and fore-reload.
  3. Start the service with sudo /etc/init.d/xrdp start, then sudo /etc/init.d/xrdp status
ubuntu xrdp daemon start initd remote desktop connection from windows
Xrdp is running on Ubuntu – ready for Remote Desktop connections!

Done! Time to remote desktop in!


Create a Remote Desktop Connection from Windows

  1. Logout of your Ubuntu session. With a default configuration, you will not be able to stay logged in to the VM from VirtualBox and also open a remote desktop connection from Windows.
  2. On Windows, open Remote Desktop, and enter the IP address associated with the second network adapter that we created previously. In this VM, it was enp0s8, with an IP address of 192.168.1.194.
Remote desktop from Windows to VirtualBox Ubuntu IP address network adapter
Use the IP address associated with the second Ubuntu network adapter with a bridged network.
  1. Once you select connect, the Remote Desktop screen will appear. If you have not modified the configuration of the xrdp.ini file on the Ubuntu host, change the connection type to Xorg.
xorg remote desktop connection windows ubuntu xrdp virtualbox vm
Xrdp default configuration: Select Xorg as the session type for Ubuntu
  1. Once you enter your username and password, you may be prompted with a message that says “Authentication Required. Authentication is required to create a color managed device”. Reenter your password and press Authenticate.
windows Ubuntu remote desktop authentication required connection
First time remote desktop connection requires authentication
  1. DONE! Look at that high resolution Remote Desktop from Windows.
Windows remote desktop connection Ubuntu vm maximum resolution xrdp xorg
Done! Remote Desktop from Windows to Ubuntu with high resolution!

Leave a Reply

Your email address will not be published.