需要手动安装 Ubuntu20.4
#!/bin/bash## This script is for Ubuntu 20.04 Focal Fossa to download and install XRDP+XORGXRDP via# source.## Major thanks to: http://c-nergy.be/blog/?p=11336 for the tips.################################################################################# Use HWE kernel packages#HWE=""#HWE="-hwe-20.04"################################################################################ Update our machine to the latest code if we need to.#if [ "$(id -u)" -ne 0 ]; thenecho 'This script must be run with root privileges' >&2exit 1fiapt update && apt upgrade -yif [ -f /var/run/reboot-required ]; thenecho "A reboot is required in order to proceed with the install." >&2echo "Please reboot and re-run this script to finish the install." >&2exit 1fi################################################################################ XRDP## Install hv_kvp utilsapt install -y linux-tools-virtual${HWE}apt install -y linux-cloud-tools-virtual${HWE}# Install the xrdp service so we have the auto start behaviorapt install -y xrdpsystemctl stop xrdpsystemctl stop xrdp-sesman# Configure the installed XRDP ini files.# use vsock transport.sed -i_orig -e 's/port=3389/port=vsock:\/\/-1:3389/g' /etc/xrdp/xrdp.ini# 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 fastersed -i_orig -e 's/bitmap_compression=true/bitmap_compression=false/g' /etc/xrdp/xrdp.ini# Add script to setup the ubuntu session properlyif [ ! -e /etc/xrdp/startubuntu.sh ]; thencat >> /etc/xrdp/startubuntu.sh << EOF#!/bin/shexport GNOME_SHELL_SESSION_MODE=ubuntuexport XDG_CURRENT_DESKTOP=ubuntu:GNOMEexec /etc/xrdp/startwm.shEOFchmod a+x /etc/xrdp/startubuntu.shfi# use the script to setup the ubuntu sessionsed -i_orig -e 's/startwm/startubuntu/g' /etc/xrdp/sesman.ini# rename the redirected drives to 'shared-drives'sed -i -e 's/FuseMountName=thinclient_drives/FuseMountName=shared-drives/g' /etc/xrdp/sesman.ini# Changed the allowed_userssed -i_orig -e 's/allowed_users=console/allowed_users=anybody/g' /etc/X11/Xwrapper.config# Blacklist the vmw moduleif [ ! -e /etc/modprobe.d/blacklist-vmw_vsock_vmci_transport.conf ]; thenecho "blacklist vmw_vsock_vmci_transport" > /etc/modprobe.d/blacklist-vmw_vsock_vmci_transport.conffi#Ensure hv_sock gets loadedif [ ! -e /etc/modules-load.d/hv_sock.conf ]; thenecho "hv_sock" > /etc/modules-load.d/hv_sock.conffi# Configure the policy xrdp sessioncat > /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-profileResultAny=noResultInactive=noResultActive=yesEOF# reconfigure the servicesystemctl daemon-reloadsystemctl start xrdp## End XRDP###############################################################################echo "Install is complete."echo "Reboot your machine to begin using XRDP."
以上命令执行后需要 设置虚拟机支持会话增强 (在完全关闭的状态执行,连接虚拟机的界面也关掉 )
Set-VM -VMName 'ubuntu' -EnhancedSessionTransportType HvSocket
