An automated, idempotent script to get Hyper-V Enhanced Session (XRDP) working on Ubuntu 24.04.
Setting up Enhanced Session on Ubuntu 24.04 is currently broken out-of-the-box using older methods. Recent Ubuntu updates introduced a performance regression with the default Xorg backend over XRDP, leading to hours upon hours of troubleshooting because the methods out there just aren't covering everything. There is way too much guesswork and they are prone to several errors along the way. I took it upon myself to find a workable solution for the latest Ubuntu Desktop 24.04.4 LTS release.
This script automates the necessary workarounds. It abandons the broken Xorg backend entirely and forces the system to use TigerVNC (tigervnc-standalone-server). It also injects the correct PAM configuration to allow the GNOME keyring to unlock properly.
- Idempotent Execution: The script checks if configurations are already applied before modifying files. It is safe to re-run if you think something broke.
- Active Session Guardrail: If you accidentally run this script while actively connected via an Enhanced Session, it will detect the
xrdp-chansrvprocess and abort. Restarting XRDP while inside it causes a "zombie" session lock, so the script prevents you from nuking your own desktop. - Dynamic Resolution & Ultrawide Support: Because the display transport is properly negotiated, you can use the Hyper-V slider to scale the VM to your monitor's exact native resolution.
- A Generation 2 Hyper-V Virtual Machine.
- In the VM Settings under Security, you MUST check Enable Secure Boot and change the Template to Microsoft UEFI Certificate Authority. (Without this, the Ubuntu ISO will not boot).
- Installed from the standard, official Ubuntu Desktop 24.04 ISO (Do NOT use Hyper-V's 'Quick Create' feature).
- During Ubuntu installation, Require my password to log in MUST be checked. XRDP will not work with auto-login.
- Your Hyper-V host must have Enhanced Session Mode allowed in its settings. You can enable this via an Admin PowerShell on Windows:
Set-VMHost -EnableEnhancedSessionMode $true Set-VM -VMName "Your_VM_Name" -EnhancedSessionTransportType HvSocket
CRITICAL: You must run it from the Basic Session console or via SSH.
- Boot your VM and log in using the Basic Session (the standard Hyper-V window).
- Open your terminal and run the one-line install command:
(Alternatively, you can manually download
wget -qO- https://raw.githubusercontent.com/Arelius-D/ubuntu-24.04-hyperv-enhanced-session/main/setup_hyperv_2404.sh | sudo bashsetup_hyperv_2404.sh, make it executable withchmod +x, and run it withsudo ./setup_hyperv_2404.sh) - Cold Boot: Once the script completes, a simple reboot is not enough for the new kernel modules (
hv_sock) to initialize correctly. You must completely power off the VM:sudo poweroff
- Start the VM again from Hyper-V Manager. You should now be prompted with the Enhanced Session resolution slider. If you don't get this behavior, simply press the icon from the top menu bar in the VM main window. Log in using the
Xvncsession drop-down, followed by your username and password.
- Audio: This script currently focuses on getting a stable, high-performance video and clipboard session running. It does not compile
pulseaudio-module-xrdpfor sound redirection. - Polkit Color Manager: You may occasionally see a prompt asking for authentication to "create a color managed device" upon login. This is a known harmless quirk that can be dismissed. (Has never happened to me, but worth mentioning).