-
-
Save mimura1133/25451be04929d65993e0fb658d0b6890 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# Original : https://raw.githubusercontent.com/Microsoft/linux-vm-tools/master/arch/install-config.sh | |
############################################################################### | |
# Update our machine to the latest code if we need to. | |
# | |
if [ "$(id -u)" -ne 0 ]; then | |
echo 'This script must be run with root privileges' >&2 | |
exit 1 | |
fi | |
apt update && apt upgrade -y | |
if [ -f /var/run/reboot-required ]; then | |
echo "A reboot is required in order to proceed with the install." >&2 | |
echo "Please reboot and re-run this script to finish the install." >&2 | |
exit 1 | |
fi | |
############################################################################### | |
# Install XRDP | |
# | |
apt install -y xrdp | |
############################################################################### | |
# Configure XRDP | |
# | |
systemctl enable xrdp | |
systemctl enable xrdp-sesman | |
# Configure the installed XRDP ini files. | |
# use vsock transport. | |
# sed -i_orig -e 's/use_vsock=false/use_vsock=true/g' /etc/xrdp/xrdp.ini | |
sed -i_orig -e 's/port=3389/port=vsock://-1:3389/g' /etc/xrdp/xrdp.ini # 2020.1 support. | |
# use rdp security. | |
sed -i_orig -e 's/security_layer=negotiate/security_layer=rdp/g' /etc/xrdp/xrdp.ini | |
# remove encryption validation. | |
sed -i_orig -e 's/crypt_level=high/crypt_level=none/g' /etc/xrdp/xrdp.ini | |
# disable bitmap compression since its local its much faster | |
sed -i_orig -e 's/bitmap_compression=true/bitmap_compression=false/g' /etc/xrdp/xrdp.ini | |
sed -n -e 's/max_bpp=32/max_bpp=24/g' /etc/xrdp/xrdp.ini | |
sed -i_orig -e 's/X11DisplayOffset=10/X11DisplayOffset=0/g' /etc/xrdp/sesman.ini | |
# rename the redirected drives to 'shared-drives' | |
sed -i_orig -e 's/FuseMountName=thinclient_drives/FuseMountName=shared-drives/g' /etc/xrdp/sesman.ini | |
# Change the allowed_users | |
echo "allowed_users=anybody" > /etc/X11/Xwrapper.config | |
#Ensure hv_sock gets loaded | |
if [ ! -e /etc/modules-load.d/hv_sock.conf ]; then | |
echo "hv_sock" > /etc/modules-load.d/hv_sock.conf | |
fi | |
# Configure the policy xrdp session | |
cat > /etc/polkit-1/localauthority/50-local.d/45-allow-colord.pkla <<EOF | |
[Allow Colord all Users] | |
Identity=unix-user:* | |
Action=org.freedesktop.color-manager.create-device;org.freedesktop.color-manager.create-profile;org.freedesktop.color-manager.delete-device;org.freedesktop.color-manager.delete-profile;org.freedesktop.color-manager.modify-device;org.freedesktop.color-manager.modify-profile | |
ResultAny=no | |
ResultInactive=no | |
ResultActive=yes | |
EOF | |
############################################################################### | |
# .xinitrc has to be modified manually. | |
# | |
#echo "exec gnome-session" > ~/.xinitrc | |
echo "exec startxfce4" > ~/.xinitrc # thanks @rasschaert and @patrickceg. | |
echo "You will have to configure .xinitrc to start your windows manager, see https://wiki.archlinux.org/index.php/Xinit" | |
echo "Reboot your machine to begin using XRDP." |
In case anyone else stumbles upon this, don't forget to set your Hyper-V VM to actually use Enhanced Session Mode:
Set-VM -VMName <your_vm_name> -EnhancedSessionTransportType HvSocket
This worked perfectly on the 2019.1 release of Kali.
i cant seem to get this command to work at all . .. invalid parameter name VMname .. Running Windows 10 v1909
Set-VM -Name acamar-kali -EnhancedSessionTransportType HvSocket
Seems to work (my VM is called acamar-kali)
The newest documentation has Set-VM -Name
... Also "-EnhancedSessionTransportType" doesn't exist in the documentation, but it tab-completes on my machine.
https://docs.microsoft.com/en-us/powershell/module/hyper-v/set-vm?view=win10-ps
If you really can't get the name to work, try
Get-VM myvm
...if that returns nothing or has an error, your PowerShell module for Hyper-V is broken.
If the Get-VM works, you can use the pipe notation to run Set-VM:
Get-VM myvm | Set-VM -EnhancedSessionTransportType HvSocket
Just thought I'd confirm that this works for me with a fresh install of Kali 2020.2 and XFCE (on Windows 10 1909, build 18363.778), though I couldn't get it to use XRDP until I tried shutting down my VM before enabling Enhanced Session Mode on the VM, after that it worked as expected.
Thanks @mimura1133
Likewise just tried it on Kali 2020.02 (upgraded hyper-v image from 2019.4), only worked once Kali was fully shut down (rather than a reboot) after that worked like a charm.
Thanks @mimura1133
FYI: for Kali 2020.3 I had to replace the sed slashes ('/') with percent signs ('%') as described here https://serverfault.com/questions/857477/sed-e-expression-unknown-option-to-s
Besides that, everything else worked great.
Thanks @mimura1133
Hi Team,
This worked fine for me earlier but I am having issue finding xrdp package in Kali Repo with Kali 2021.1 ( it 404ed ),
anyone hitting the same issue,
( though if i get the repo via deb.debian then it also doesn't works )
any advice would be really appreciated :)
Hi @holidayz1,
Could you please check with https://github.com/mimura1133/linux-vm-tools/blob/master/kali/2020.x/install.sh ?
the gist had moved to https://github.com/mimura1133/linux-vm-tools/ repo.
Thanks @mimura1133
yes, I believe tried https://github.com/mimura1133/linux-vm-tools/blob/master/kali/2020.x/install.sh , It didn't worked.
Though I tried linux-vm-tools/ubuntu/19.04/install.sh since i got xrdp from deb.debian and it worked like a charm
Hi @holidayz1,
Unfortunately, I have not been able to reproduce the problem with clean installation.
However, if you using GNOME (gdm3) or latest version of xrdp, the ubuntu/19.04/install.sh be better, as you said.
if you're using GNOME shell (gdm3), need to set "WaylandEnable=false" at /etc/gdm3/custom.conf, because the xrdp will use Xorg.
other changes are in the way the VSOCK settings are written.
If you know of a way to improve the code in the kali version, please send us a pull request, thanks. :)
still could not get enhanced session enabled on kali 2020.1 with default installation. the script does not error out but the enhanced session mode will not activate for some reason.
any clues? after the reboot the system still boots to lightdm instead of xrdp login screen as in ubuntu
and set-vm -VMname is an invalid parameter at least on windows 10 v1909 . and what i know is that enhanced session mode is enabled by default on windows 10 .