xRDP – Hyper-v Enhanced mode for Ubuntu through xRDP software – Revisited

Hello World, 

Since we have recently released the latest version of our famous xrdp-installer script (version 1.3 is out ! ), we have been quite busy with xRDP and Ubuntu as virtual machines.  In a previous post, we have been testing and checking how to provide enhanced mode when Ubuntu machine is a virtual machine running on top of Hyper-v.    All in all, using a specific bash script created by some folks, it was possible to connect to an Ubuntu machine from the Hyper-v manager and enable the enhanced mode which provide better user experience (you are basically using RDP protocol).

However, the last time we checked the tool,  it was not possible at the same time to have enhanced mode enabled and remotely connect to the Ubuntu VM through RDP... This was a no go… 

In this post, we will revisit this topic and provide a different approach…Instead of using the provided script, we will use our famous xrdp-installer script and see if we can overcome the limitation of not being able to access the machine remotely via the network….

Note : 

We are aware that you can now use the Quick Create VM option in Hyper-v  (on Windows 10) to deploy your Ubuntu VM and the enhanced mode should be enabled by default when using the image provided by Microsoft.  Since we are not really using the Quick Create VM approach, we do not really know what are features and possible limitations that can occur….Our scenario is a little bit different since we are targeting Hyper-V on Windows Servers….

So, let’s go ! 

Overview

In this previous post, the following steps were needed in order to have enhanced mode enabled for Ubuntu machines on top of Hyper-v Hypervisor servers 

  • Download the script (used to install xrdp package and perform some configuration changes) 
  • Execute the script 
  • Stop the VM & enable EnhancedModeTransportType via Powershell 

When this was done,  a user would have the possibility to use enhanced mode from the Hyper-v Manage Console 

Click on Picture for Better Resolution

Click on Picture for Better Resolution

However, if the same user would need to remotely access the Ubuntu Desktop, this would not work…. Connection from network will not go through 

Click on Picture for Better Resolution

Our approach 

Since we are working in environment where virtualization platform is provided by Hyper-V Server, and since Ubuntu VMs are more and more present within organizations, we started to had requirements to use enhanced mode and allow remote connections from the network as well… In the following section, we explain how we can tackle this…. 

Step 1 – Using our famous xrdp-installer-xx script 

So, in our approach, instead of using the provided script by the team behind this effort, we have decided to run our famous xrdp-installer script.  By running the script, we will enable the possibility to perform the remote desktop connection via the network (using mstsc client).   However, when the script complete, you will immediately notice that it’s not possible to have enhanced mode available 

Click on Picture for Better Resolution

However, at this stage, you will be able to access the desktop interface via remote desktop protocol as long as the machine is accessible via the network…. Enhanced mode is still not available….

Step 2 – Adding Enhanced mode to the VM….

To add and enable enhanced mode for this Ubuntu VM, you will simply need to edit the /etc/xrdp/xrdp.ini file… Simply follow these necessary steps 

1 – Edit /etc/xrdp/xrdp.ini in read-write mode 

sudo nano /etc/xrdp/xrdp.ini

Click on Picture for Better Resolution

2- Locate the section (in the beginning of the file) about ports section 

As shown in the screenshot, you should see by default the line 

port=3389

Click on Picture for Better Resolution

We will replace this line with the following settings as shown in the picture below

port=vsock://-1:3389 tcp://:3389

singlepic id=4443 w=320 h=240 float=center]

Click on Picture for Better Resolution

3 – Change security layer settings

By default, xrdp will use the tls security layer but it seems that this setting is enabled, the enhanced mode connection is simply not working.   We have to replace the security layer from TLS to rdp as shown in the picture below.  If you do not do that, you will never be able to use the enhanced mode   

Click on Picture for Better Resolution

4 – Power Off the VM 

We will need to power off the VM in order to enable some advanced settings through PowerShell…No reboot, no restart, a proper power off !!!

5 – Enabled EnhancedSessionTransport Type on the Ubuntu VM 

When the VM is turned off, you can fire up your PowerShell console and issue the following command 

Set-VM -VMName <your_vm_name> -EnhancedSessionTransportType HvSocket

Click on Picture for Better Resolution

6 – Restart the Virtual machine  

If everything is setup correctly, during the boot process of your vm, you should see a dialog box asking you about display configuration… If you see this popup box, this means that enhanced mode is indeed enabled

Click on Picture for Better Resolution

 

7 – Test your console connection using Hyper-V manager mmc console

Let’s the VM boot up completely and display the login screen.   You can see and check that since we have changed our settings in the xRDP file, we are indeed running the VM with enhanced mode enable

Click on Picture for Better Resolution

When you click on the user to login,  you will see (within the enhance mode VM console) the classical xRDP login screen  

Click on Picture for Better Resolution

Simply provide the necessary credentials and you should be able to access the Ubuntu Desktop interface through the Hyper-v console and still have enhanced mode enabled  

Click on Picture for Better Resolution

8 – Test accessing the VM via remote desktop client 

 It’s time to check if we can access the Ubuntu VM machine from the network using remote desktop protocol and the MSTSC.exe tool from Microsoft.  Fire up your remote desktop client, digit the ip or name of the VM host and you should see the standard login screen provided by xRDP 

Click on Picture for better Resolution

After passing valid credentials, you will see that you have indeed access to the Desktop interface via the network  

Click on Picture for Better Resolution

If you were logged into the VM Connection manager (Hyper-V) and you perform the standard rdp connection, the VM connection will be disconnected and you will be able to access the Ubuntu Desktop interface.  This would be the same behavior if you were connected via RDP session,  if you login into the Virtual machine connection, you will be disconnected from the RDP session   

Click on Picture for Better Resolution

 

Final Notes

Voila ! This is it for this post.. 

We have seen that using our famous xrdp-installer script it’s possible to perform rdp connection to your Ubuntu VM hosted on an Hyper-v server.  Moreover, by tweaking the xrdp configuration, it’s also possible in addition to the remote desktop session to enable enhanced session mode for the VM as well.  The configuration is quite straightforward and easy to implement.  We have not extensively tested this but it seems to work accordingly…  Give it a try and provide feedback  🙂 

Till Next time 

See ya

 

2 thoughts on “xRDP – Hyper-v Enhanced mode for Ubuntu through xRDP software – Revisited

  1. Great script. Just one question. On my setup I’ve found that I need to manually start Xrdp to get the “Enhanced Session” active and the “resolution window” by using “sudo /etc/init.d/xrdp start” command. Is there a way to configure it for an automatic VM start every time ? Thanks.

  2. @Tomasz,

    When you install the xRDP package, associated services are created.. So normally, you should not need to perform any start or restart actions…. Possibly, you would need to check that your Hypervisor is configure to present you with the Enhanced mode when available… This is a setting that you have to check and enable at Hyper-V console level
    Hope this help
    Till next time
    See ya

Leave a Reply