Post

Enable Enhanced Session on Linux VMs in HyperV

Enable Enhanced Session on Linux VMs in HyperV

HyperV is trash, cooked and shouldn’t be used but have to since it’s fast and easy to manage because VBox is too slow and I don’t wanna make a broadcom account (Despite knowing they have all my data lol) for vmware, Qemu is also slower on Windows. So yeah, Was setting up Parrot/Pop_OS! vms the other day and this is common problem among HyperV.

Gold old days, when you could just download vmware and setup AD-Labs really well.

Prerequisites

We need to install some dependencies that are might not be pre-installed on Parrot OS VM that we have in Hyper-V.

1
sudo apt-get -y install hyperv-daemons pulseaudio-module-xrdp xrdp

This is going to install hyperv-daemons which is a utility to improve user interaction on Linux VMs in Hyper-V. And then pulseaudio-module-xrdp which provides audio redirection support for XRDP. xrdp is important since it enhanced session is over rdp. Enable rdp.

1
sudo systemctl enable xrdp

Using Kali Tweaks script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
# vim: et sts=4 sw=4

# Configure XRDP, cf. xrdp.ini(5).
# * use vsock transport
# * use rdp security
# * remove encryption validation
# * disable bitmap compression, since its local its much faster
#
# Note: there are several 'port=' statements in the config file,
# we match 'port=3389' (the default value) to make sure to change
# only this line.
cp -f --preserve=all "/etc/xrdp/xrdp.ini" "/etc/xrdp/xrdp.ini.backup"
sed -i \
    -e 's|^ *port=3389|port=vsock://-1:3389|' \
    -e 's|^ *security_layer=.*|security_layer=rdp|' \
    -e 's|^ *crypt_level=.*|crypt_level=none|' \
    -e 's|^ *bitmap_compression=.*|bitmap_compression=false|' \
    /etc/xrdp/xrdp.ini

# Configure the XRDP session manager, cf. sesman.ini(5).
# * set the first X display number available for xrdp-sesman to 0
# * rename the redirected drives to 'shared-drives'.
cp -f --preserve=all "/etc/xrdp/sesman.ini" "/etc/xrdp/sesman.ini.backup"
sed -i \
    -e 's|^ *X11DisplayOffset=.*|X11DisplayOffset=0|' \
    -e 's|^ *FuseMountName=.*|FuseMountName=shared-drives|' \
    /etc/xrdp/sesman.ini

# Ensure the Hyper-V sockets module gets loaded.
echo "hv_sock" > /etc/modules-load.d/hv_sock.conf
systemctl restart systemd-modules-load.service

chmod it

I know you are not skid, but yeah have to do it yk.

1
2
chmod +x runme.sh
bash runme.sh

Now restart your Hyper-V VM and you should have the Enhanced Session. In case kali-tweaks script doesn’t work you can try this one.

Now you have done all the steps BUT you need to enable HVSocket for the VM via PowerShell, Run it as Administrator and Exec the below Command:

You need to enable the HVSocket on the VM

1
Set-VM "Your VM Name" -EnhancedSessionTransportType HVSocket

Done

After doing all the steps above, you should get the prompt to change your resolution,

Side Note

if you on Pop_OS!, you can use this script and if still doesn’t work even if you get xrdp prompt,

It’s likely gnome is not letting you do RDP in. Read More Here

This post is licensed under CC BY 4.0 by the author.