xRDP – Easy install xRDP on Ubuntu 18.04,20.04,20.10,21.04 (Script Version 1.2.3)

  The script hereafter is outdated and has been replaced by a newer version.  Please Check the Download page for latest version. 

Hello World, 

Since Ubuntu 21.04 has been released (April 2021), it’s time for us to update and publish the latest version of our famous xrdp-installer script. As we tend to follow the Ubuntu life cycle, we tend to update our script to include supported version of Ubuntu Operating system.  This new release will basically include support for Ubuntu 21.04 but it will also introduce some important changes that you need to be aware of (no support for Ubuntu 16.04 anymore !!!)

The new version of our famous xrdp installation script will be set to 1.2.3 (i.e. xrdp-installer-1.2.3.sh).  This script replaces all previous versions.   

Note : This script should be seen as a quick maintenance release to include Ubuntu 21.04. A new version of the script is being worked out which will be released at a later time….

So, let’s go ! 

Overview

The xrdp-installer-1.2.3.sh script ease the installation and post-configuration actions of xRDP on top of Ubuntu Operating System.  This version is the latest iteration of the script which include support for Ubuntu 21.04 (recently released in April 2021). 

What’s new in this release (Version 1.2.3) ?

While the script structure and code has not changed drastically, Version 1.2.3 introduce some important changes that you have to be aware of. 

Removed Ubuntu 16.04 as supported OS !

Since Ubuntu 16.04.x has reached end of standard support, the xrdp-installer script has removed support for Ubuntu 16.04.x.    Version 1.3 of the script will not run on Ubuntu 16.04.x !  

If you still need to support Ubuntu 16.04.x, please use the xrdp-installer-1.2.2.sh version of the script to perform your xRDP installation. Use the script at your own risk as we will not provide anymore any updates for Ubuntu 16.04 Support 

Note : Visit our archive Repository page to retrieve previous version of the script

Added Ubuntu 21.04 as supported OS !

Since Ubuntu 21.04 has been released, we have adapted the script in order to include support of the latest Operating System version.  The script can be run against Ubuntu 21.04. 

Improved removed function  

The script allows you to uninstall the xRDP installation previously performed with the script.  The previous script was removing only basic information from the system. Script version 1.2.3 checks more settings and delete files that are not needed anymore.   There is still room for improvements and we will probably perform that in the next iteration of the script 

Minor Bug Fixing, Cleaning up code 

We have found some small bugs or minor issues that have been fixed or improved in this release. We have also modified a little bit the code structure but nothing major  

Download the Script 

The script can be download at this location  :    xrdp-installer-1.2.3.zip 

Note : All the xrdp scripts can be found at https://www.c-nergy.be/products.html

How to Use the Script

A downloadable version of the script is available at the bottom of the post

The xrdp-installer-1.2.3 script will work in a similar way as the previous versions. The following section will explain how to download, extract, set executable mode and perform the installation using the script.  The script provides some switches that can be used to customize the installation process.

So, let’s see how this would be working…. 

Disclaimer

The script is provided AS IS.  Use it at your own risk !!! 

Prerequisites and assumptions  

The following conditions should be met in order to have the best results while using the script

  • We assume that your machine is connected to internet while performing the installation.  This is needed as additional packages and software needs to be downloaded and installed on your Ubuntu machine
  • The script runs against a supported Operating system (Ubuntu 18.04.x, Ubuntu 20.04, Ubuntu 20.10, Ubuntu 21.04)
  • The Official Ubuntu distribution needs to be used (we do not support other Ubuntu flavors so far  !!)
  • No additional Desktop interface is used ( xRDP session will be showing Ubuntu Gnome Desktop with the Dock menu)
  • Sound functionality is present on the computers if you sound feature is available as well

Script version & Supported Ubuntu Version

The xrdp-installer-1.2.3.sh script will support the following Ubuntu operating system version 

  • Ubuntu 18.04.x
  • Ubuntu 20.04.x
  • Ubuntu 20.10.x
  • Ubuntu 21.04.x

Ubuntu 16.04.x is not anymore a supported OS version with the xrdp-installer-1.3.sh script ! 

Step 1 – Download the script 

To download the script, you have multiple options.   You can from a Terminal issue the following command 

wget https://www.c-nergy.be/downloads/xRDP/xrdp-installer-1.2.3.zip

You can also simply use your browser and click on the link to download the script :  

  •  xrdp-installer-1.2.3.zip

Step 2 – unzip the file 

After downloading the zip package containing the file, you will need to unzip it first. To unzip the package, you can use the Terminal console and issue the following command 

unzip xrdp-installer-1.2.3.zip 

You can also use the GUI and the Nautilus file manager to select the downloaded package, right-click on it and select the option Extract Here

Step 2 – Set Execute Right on the script

Download the xrdp-installer-1.2.3.sh script to your system, extract content and mark it as executable . To do this, perform the following action in a terminal console

chmod +x  ~/Downloads/xrdp-installer-1.2.3.sh

Note : Adjust the path where the xrdp-Installer-1.2.3.sh script to reflect your environment

Step 2 – Run as normal user 

The script needs to be run as a normal user.  The script will start running and will prompt you for password when sudo actions are initiated.  If you run the script as root or using sudo command, the Download folder does not exist for the root user and the script fails to run as expected.   To overcome this situation, the script also check which user is executing the script. If the script is run under sudo or root accounts, a warning message will be displayed and the script will not execute

Step 3 – Switches and parameters 

The xrdp-installer-1.2.3.sh script can be executed as is (with no parameters or switches). This will perform a standard (and basic) installation of xRDP.  No sound or custom xrdp login script will be made available.  However, remote desktop, drive redirection and clipboard redirection would be available with this installation mode.  

The xrdp-installer-1.2.3.sh script accept also some additional parameters that will help customize the xrdp installation and enable additional features.  The script provides the following parameters 

--help or -h          => will display a basic help menu
--sound or -s         => will enable sound redirection 
--loginscreen or -l   => will customize the xRDP login screen 
--remove or -r        => will remove the xrdp package 
--custom or -c        => will perform a custom installation (i.e. compiled from sources)

Step 4 – Perform xRDP installation using the script 

The following sections will provide some examples and scenario on how you can use the script….. 

Standard Installation – No Parameter

As mentioned above, you can decide to use the default xrdp package available in the Ubuntu repository and perform a basic installation which will provide you remote desktop capability and will also customize the remote sesssion.  The script will ensure that the same look n’ feel will be maintained when the user logs on locally or remotely. 

To perform a standard installation, you execute the script with no parameters.  Open a Terminal console, browse to the location where the script has been downloaded and issue the following command 

 ./xrdp-installer-1.2.3.sh

When the xrdp installation package will start, you be requested to enter your password. Provide the password and proceed with the installation. Wait for completion of the script.  The machine will not reboot automatically when done so you can review the actions performed by the script….

Standard Installation with Parameters

The script can be used to perform a standard installation and still passes some parameters to get the most of the xRDP packages and their features.  For all the Ubuntu versions, we could use the following combination of parameters 

./xrdp-installer-1.2.3.sh -s      (this would enable the sound redirection) 
./xrdp-installer-1.2.3.sh -l      (this would customize the xrdp login screen -see here)

Obviously, you can combine the switches (any order) to have more features enabled  

./xrdp-installer-1.2.3.sh -s -l      (this would enable the sound redirection and customize the xrdp login screen)

Important Notes

The script can be run multiple times on the same machine.  If you have run initially the script with no parameters but you decide afterward to enable additional features, the script can be re-executed and the additional features will be enabled.  

Custom Installation – Default Installation 

Custom installation script is really flexible. Custom installation means that the script will compile the xrdp package from the source binaries. The custom installation script always uses the latest xrdp package version available 

To perform a custom installation, you will need at minimum to pass one parameter.  The following command line shows you how to perform a custom installation  

./xrdp-installer-1.2.3.sh -c     (this would perform a custom installation but will not enabled adv features like sound redirection or custom login screen)

Custom Installation – Additional Options  

If a user wants to enable additional features, you will pass some additional parameters as shown in the following examples 

./xrdp-installer-1.2.3.sh -c -s     (this would perform a custom install and enable sound redirection)
./xrdp-installer-1.2.3.sh -c -l     (this would perform a custom install and customize xrdp login screen)
./xrdp-installer-1.2.3.sh -c -l -s  (this would perform a custom install, enable sound and customize login screen)

Important Notes

The script can be run multiple times on the same machine.  If you have run initially the script with no parameters but you decide afterward to enable additional features, the script can be re-executed and the additional features will be enabled.  

Remove Installation option

This version of the script also ship with the option to remove xRDP package.  The removal option should be only used  if you have uses this version of this script to perform the installation.  To remove the xrdp package, you would simply execute the following command  

./xrdp-installer-1.2.3.sh -r     (to remove the xrdp packages)

Step 5 – Test your configuration 

After the script has run and after the reboot/shutdown and start process, it’s time to test and see if you can indeed perform a smooth remote connection to your Ubuntu machine.  Start your favorite rdp client and simply enter your credentials and start testing your installation.  If everything is ok, you will see a similar Desktop interface where Gnome Desktop is used and the Dock is visible. 

Known issues and limitations 

Known Issues 

Drive Redirection  

To redirect your drives to your xrdp remote session, you have to ensure that the only option selected in the local resources tab are the Clipboard option and the drive option. Check the screenshot below and ensure that you have the same settings.

Click on picture for better resolution

Click on picture for better resolution

When these settings have been set accordingly, you should see the thin client folder populated with redirected drives coming from your Windows machine.

Sound redirection Issue

If the Sound redirection option has been selected, rebooting the Ubuntu system is not enough and the sound redirection might not work.  if the sound redirection option has been selected, you will have to shutdown your Ubuntu machine and then start it again in order to ensure that the sound redirection feature would work as expected. 

Sound redirection is not working as expected on Ubuntu 19.10 and later  The modules are created and copied to the correct location. However, the xrdp sink modules are never loaded in the remote session or randomly loaded in the remote session.   To fix this, you simply need to execute the following command within your remote session and the sound will start working 

pulseaudio -k

Black Screen or disconnected immediately after connecting

As mentioned and explained multiple times,  this situation will happen (or can happen) when the same user account is used concurrently locally and remotely.  In other words,  the problem is related to the fact that the same user account is already logged in locally and a remote connection is attempted at the same time.  With xRDP software solution, a specific user account can be logged on either locally or remotely but not both….  

You can read more information and some workarounds (provided as is) to try to fix the issues in the following posts 

Limitations

Switch between standard and Custom install

This version of the script can be run multiple times on the same machine.  However, because of this new behavior, you cannot perform a standard installation and then decide to perform the custom installation.  Once you have selected your installation mode, you will have to stick to it.  This is kind of checked by the script.  

So, if you have performed a standard installation but afterwards you might want to use the custom installation option, the script will ignore the request.  If you want to move from standard install mode to custom mode (or vice versa), the correct process is 

  • remove xrdp (using the xrdp-installer-1.3.sh -r option) 
  • perform a new installation using your selected installation mode (standard or custom install mode) 

Download the Script 

The script can be download at this location  :    xrdp-installer-1.2.3.zip 

Note : All the xrdp scripts can be found at https://www.c-nergy.be/products.html

Final Notes

This is it for this post !  

Please if you have time or want to help us in creating the best xrdp installer script, download the script, test it and provide constructive feedback.  If you find a bug or an issue with the script, let us know as well so we can try to fix it.  

Till next time

Annex – The Script Source code 

#!/bin/bash
#####################################################################################################
# Script_Name : xrdp-installer-1.2.3.sh
# Description : Perform xRDP installation on Ubuntu 18.04,20.4,20.10,21.04 and perform
#               additional post configuration to improve end user experience
# Date : May 2021
# written by : Griffon
# WebSite :http://www.c-nergy.be - http://www.c-nergy.be/blog
# Version : 1.2.3 
# History : 1.2.3 - Adding support for Ubuntu 21.04 
#                 - Removing Support for Ubuntu 16.04.x (End Standard Support)
#                 - Delete xrdp and xorgxrdp folder when remove option selected
#                 - Review remove function to detect hwe package U18.04
#                 - Review, Optimize, Cleanup Code 
#         : 1.2.2 - Changing Ubuntu repository from be.archive.ubuntu.com to archive.ubuntu.com
#                 - Bug Fixing - /etc/xrdp/xrdp-installer-check.log not deleted when remove option   
#                   selected in the script - Force Deletion (Thanks to Hiero for this input)     
#                 - Bug Fixing - Grab automatically xrdp/xorgxrdp package version to avoid     
#                   issues when upgrade operation performed (Thanks to Hiero for this input)     
#         : 1.2.1 - Adding Support to Ubuntu 20.10 + Removed support for Ubuntu 19.10
#           1.2   - Adding Support to Ubuntu 20.04 + Removed support for Ubuntu 19.04
#                 - Stricter Check for HWE Package (thanks to Andrej Gantvorg)
#                 - Changed code in checking where to copy image for login screen customization 
#                 - Fixed Bug checking SSL group membership 
#                 - Updating background color xrdp login screen 
#                 - Updating pkgversion to x.13 for checkinstall process
#         : 1.1   - Tackling multiple run of the script 
#                 - Improved checkinstall method/check ssl group memberhsip
#                 - Replaced ~/Downloads by a variable                 
#         : 1.0   - Added remove option + Final optimization                
#         : 0.9   - updated compile section to use checkinstall
#         : 0.8   - Updated the fix_theme function to add support for Ubuntu 16.04 
#         : 0.7   - Updated prereqs function to add support for Ubuntu 16.04
#         : 0.6   - Adding logic to detect Ubuntu version for U16.04 
#         : 0.5   - Adding env variable Fix 
#         : 0.4   - Adding SSL Fix 
#         : 0.3   - Adding custom login screen option  
#         : 0.2   - Adding new code for passing parameters  
#         : 0.1   - Initial Script (merging custom & Std)       
# Disclaimer : Script provided AS IS. Use it at your own risk....
#              You can use this script and distribute it as long as credits are kept 
#              in place and unchanged   
####################################################################################################
#--------------------------------------------------------------------------#
# -----------------------Function Section - DO NOT MODIFY -----------------#
#--------------------------------------------------------------------------#
############################################################################
# DEFAULT INSTALLATION MODE : STANDARD INSTALLATION 
############################################################################
#---------------------------------------------------#
# Function 1  - check xserver-xorg-core package....
#---------------------------------------------------#

check_hwe()
{
Release=$(lsb_release -sr)
echo
/bin/echo -e "\e[1;33m |-| Detecting xserver-xorg-core package installed \e[0m"
xorg_no_hwe_install_status=$(dpkg-query -W -f ='${Status}\n' xserver-xorg-core 2>/dev/null)
xorg_hwe_install_status=$(dpkg-query -W -f ='${Status}\n' xserver-xorg-core-hwe-$Release 2>/dev/null) 

if [[ "$xorg_hwe_install_status" =~ \ installed$ ]]
then
# – hwe version is installed on the system
/bin/echo -e "\e[1;32m  |-| xorg package version: xserver-xorg-core-hwe \e[0m"
HWE="yes"
elif [[ "$xorg_no_hwe_install_status" =~ \ installed$ ]]
then
/bin/echo -e "\e[1;32m  |-| xorg package version: xserver-xorg-core \e[0m"
HWE="no"
else
/bin/echo -e "\e[1;31m  |-| Error checking xserver-xorg-core flavour \e[0m"
exit 1
fi
}

#---------------------------------------------------#
# Function 2  - Install xRDP Software....
#---------------------------------------------------#

install_xrdp()
{
echo
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
/bin/echo -e "\e[1;33m   !   Installing XRDP Packages...Proceeding...  !\e[0m"
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
echo

if [[ $HWE = "yes" ]] && [[ "$version" = *"Ubuntu 18.04"* ]];
then
    sudo apt-get install xrdp -y
    sudo apt-get install xorgxrdp-hwe-18.04
else
    sudo apt-get install xrdp -y
fi
}

############################################################################
# ADVANCED INSTALLATION MODE : CUSTOM INSTALLATION
############################################################################
#---------------------------------------------------#
# Function 0 - Install Prereqs...
#---------------------------------------------------#

install_prereqs() {
echo
Release=$(lsb_release -sr)
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
/bin/echo -e "\e[1;33m   !   Installing PreReqs packages..Proceeding.  ! \e[0m"
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
echo
sudo apt-get -y install libx11-dev libxfixes-dev libssl-dev libpam0g-dev libtool libjpeg-dev flex bison gettext autoconf libxml-parser-perl libfuse-dev xsltproc libxrandr-dev python3-libxml2 nasm fuse pkg-config git intltool checkinstall
echo
if [ $HWE = "yes" ];
then
    # - xorg-hwe-* to be installed
    /bin/echo -e "\e[1;32m       |-| xorg package version: xserver-xorg-core-hwe-$Release \e[0m"
    sudo apt-get install -y xserver-xorg-dev-hwe-$Release xserver-xorg-core-hwe-$Release    
else
    #-no-hwe
    /bin/echo -e "\e[1;32m       |-| xorg package version: xserver-xorg-core \e[0m"
    echo
    sudo apt-get install -y xserver-xorg-dev xserver-xorg-core
fi
}

#---------------------------------------------------#
# Function 1 - Download XRDP Binaries... 
#---------------------------------------------------#

get_binaries() { 
echo
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
/bin/echo -e "\e[1;33m   !   Download xRDP Binaries.......Proceeding.  ! \e[0m"
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
echo
#cd ~/Downloads
Dwnload=$(xdg-user-dir DOWNLOAD)
cd $Dwnload
## -- Download the xrdp latest files
echo
/bin/echo -e "\e[1;32m   !---------------------------------------------!\e[0m"
/bin/echo -e "\e[1;32m   !  Preparing download xrdp package            !\e[0m"
/bin/echo -e "\e[1;32m   !---------------------------------------------!\e[0m"
echo
git clone https://github.com/neutrinolabs/xrdp.git
echo
/bin/echo -e "\e[1;32m   !---------------------------------------------!\e[0m"
/bin/echo -e "\e[1;32m   !  Preparing download xorgxrdp package        !\e[0m"
/bin/echo -e "\e[1;32m   !---------------------------------------------!\e[0m"
echo
git clone https://github.com/neutrinolabs/xorgxrdp.git
}

#---------------------------------------------------#
# Function 2 - compiling xrdp... 
#---------------------------------------------------#

compile_source() { 
echo
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
/bin/echo -e "\e[1;33m   !   Compile xRDP packages .......Proceeding.  !\e[0m"
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
echo
#cd ~/Downloads/xrdp
cd $Dwnload/xrdp
#Get the release version automatically
pkgver=$(git describe  --abbrev=0 --tags  | cut -dv -f2)
sudo ./bootstrap
sudo ./configure --enable-fuse --enable-jpeg --enable-rfxcodec
sudo make
#-- check if no error during compilation 
if [ $? -eq 0 ]
then 
/bin/echo -e "\e[1;33m   |-| Make Operation Completed successfully       \e[0m"
else 
echo
echo
/bin/echo -e "\e[1;31m   !---------------------------------------------!\e[0m"
/bin/echo -e "\e[1;31m   !   Error while Executing make                !\e[0m"
/bin/echo -e "\e[1;31m   !   The Script is exiting....                 !\e[0m"
/bin/echo -e "\e[1;31m   !---------------------------------------------!\e[0m"
exit
fi

sudo checkinstall --pkgname=xrdp --pkgversion=$pkgver --pkgrelease=1 --default

#xorgxrdp package compilation
echo
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
/bin/echo -e "\e[1;33m   !   Compile xorgxrdp packages....Proceeding.  !\e[0m"
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
echo
#cd ~/Downloads/xorgxrdp 
cd $Dwnload/xorgxrdp
#Get the release version automatically

pkgver=$(git describe  --abbrev=0 --tags  | cut -dv -f2)
sudo ./bootstrap 
sudo ./configure 
sudo make

# check if no error during compilation 
if [ $? -eq 0 ]
then 
echo
/bin/echo -e "\e[1;33m   |-| Make Operation Completed successfully       \e[0m"
echo
else 
echo
/bin/echo -e "\e[1;31m   !---------------------------------------------!\e[0m"
/bin/echo -e "\e[1;31m   !   Error while Executing make                !\e[0m"
/bin/echo -e "\e[1;31m   !   The Script is exiting....                 !\e[0m"
/bin/echo -e "\e[1;31m   !---------------------------------------------!\e[0m"
exit
fi

sudo checkinstall --pkgname=xorgxrdp --pkgversion=1:$pkgver --pkgrelease=1 --default
}

#---------------------------------------------------#
# Function 3 - create services .... 
#---------------------------------------------------# 

enable_service() {
echo
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
/bin/echo -e "\e[1;33m   !   Creating xRDP services.......Proceeding.  !\e[0m"
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
echo 
sudo systemctl daemon-reload
sudo systemctl enable xrdp.service
sudo systemctl enable xrdp-sesman.service
sudo systemctl start xrdp
}

############################################################################
# COMMON FUNCTIONS - WHATEVER INSTALLATION MODE 
############################################################################

#---------------------------------------------------#
# Function 0 - Install Gnome Tweak Tool.... 
#---------------------------------------------------#

install_tweak() 
{
echo
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
/bin/echo -e "\e[1;33m   !   Installing Gnome Tweak...Proceeding...    !\e[0m"
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
echo
sudo apt-get install gnome-tweak-tool -y
}

#--------------------------------------------------------------------#
# Fucntion 1 - Allow console Access ....(seems optional in u18.04)
#--------------------------------------------------------------------#

allow_console() 
{
echo
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
/bin/echo -e "\e[1;33m   !   Granting Console Access...Proceeding...   !\e[0m"
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
echo
sudo sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config
}

#---------------------------------------------------#
# Function 2 - create policies exceptions .... 
#---------------------------------------------------#

create_polkit()
{
echo
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
/bin/echo -e "\e[1;33m   !   Creating Polkit File...Proceeding...      !\e[0m"
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
echo

#All Ubuntu version
sudo bash -c "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

#Specific Versions
if [[ "$version" = *"Ubuntu 20.10"* ]] || [[ "$version" = *"Ubuntu 20.04"* ]] || [[ "$version" = *"Ubuntu 21.04"* ]];
then
sudo bash -c "cat >/etc/polkit-1/localauthority/50-local.d/46-allow-update-repo.pkla" <<EOF
[Allow Package Management all Users]
Identity=unix-user:*
Action=org.freedesktop.packagekit.system-sources-refresh
ResultAny=yes
ResultInactive=yes
ResultActive=yes
EOF
fi

}

#---------------------------------------------------#
# Function 3 - Fixing Theme and Extensions .... 
#---------------------------------------------------#

fix_theme()
{
echo
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
/bin/echo -e "\e[1;33m   !   Fix Theme and extensions...Proceeding...  !\e[0m"
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"

# Checking if script has run already 
if [ -f /etc/xrdp/startwm.sh.griffon ]
then
sudo rm /etc/xrdp/startwm.sh
sudo mv /etc/xrdp/startwm.sh.griffon /etc/xrdp/startwm.sh
fi 

#Backup the file before modifying it
sudo cp /etc/xrdp/startwm.sh /etc/xrdp/startwm.sh.griffon

#Updating the startwm.sh accordingly 
echo
sudo sed -i "4 a #Improved Look n Feel Method\ncat <<EOF > ~/.xsessionrc\nexport GNOME_SHELL_SESSION_MODE=ubuntu\nexport XDG_CURRENT_DESKTOP=ubuntu:GNOME\nexport XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg\nEOF\n" /etc/xrdp/startwm.sh
echo
}

#---------------------------------------------------#
# Function 4 - Enable Sound Redirection .... 
#---------------------------------------------------#

enable_sound()
{
echo
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
/bin/echo -e "\e[1;33m   !   Enabling Sound Redirection...             !\e[0m"
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m"
echo
# Step 1 - Enable Source Code Repository
sudo apt-add-repository -s -y 'deb http://archive.ubuntu.com/ubuntu/ '$codename' main restricted'
sudo apt-add-repository -s -y 'deb http://archive.ubuntu.com/ubuntu/ '$codename' restricted universe main multiverse'
sudo apt-add-repository -s -y 'deb http://archive.ubuntu.com/ubuntu/ '$codename'-updates restricted universe main multiverse'
sudo apt-add-repository -s -y 'deb http://archive.ubuntu.com/ubuntu/ '$codename'-backports main restricted universe multiverse'
sudo apt-add-repository -s -y 'deb http://archive.ubuntu.com/ubuntu/ '$codename'-security main restricted universe main multiverse'
sudo apt-get update

# Step 2 - Install Some PreReqs
sudo apt-get install git libpulse-dev autoconf m4 intltool build-essential dpkg-dev libtool libsndfile-dev libcap-dev -y libjson-c-dev
sudo apt build-dep pulseaudio -y

# Step 3 -  Download pulseaudio source in /tmp directory - Do not forget to enable source repositories
cd /tmp
sudo apt source pulseaudio
# Step 4 - Compile
pulsever=$(pulseaudio --version | awk '{print $2}')
cd /tmp/pulseaudio-$pulsever
sudo ./configure

# step 5 - Create xrdp sound modules
sudo git clone https://github.com/neutrinolabs/pulseaudio-module-xrdp.git
cd pulseaudio-module-xrdp
sudo ./bootstrap 
sudo ./configure PULSE_DIR="/tmp/pulseaudio-$pulsever"
sudo make

#Step 6 copy files to correct location (as defined in /etc/xrdp/pulse/default.pa)
cd /tmp/pulseaudio-$pulsever/pulseaudio-module-xrdp/src/.libs
sudo install -t "/var/lib/xrdp-pulseaudio-installer" -D -m 644 *.so
sudo install -t "/usr/lib/pulse-$pulsever/modules" -D -m 644 *.so
echo
}

#---------------------------------------------------#
# Function 5 - Custom xRDP Login Screen .... 
#---------------------------------------------------#

custom_login()
{
echo 
/bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" 
/bin/echo -e "\e[1;33m ! Customizing xRDP login screen               !\e[0m" 
/bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" 
echo 
Dwnload=$(xdg-user-dir DOWNLOAD)
echo "go to Download folder"
echo
echo $Dwnload
#cd ~/Downloads
cd $Dwnload
#chek if file exists if not - download it.... 

if [ -f "griffon_logo_xrdp.bmp" ]
then
echo "custom logo file already present..."
else
wget http://www.c-nergy.be/downloads/griffon_logo_xrdp.bmp
fi

#Check if script has run once...
if [ -f /etc/xrdp/xrdp.ini.griffon ]
then
sudo rm /etc/xrdp/xrdp.ini
sudo mv /etc/xrdp/xrdp.ini.griffon /etc/xrdp/xrdp.ini
fi 

#Backup file 
sudo cp /etc/xrdp/xrdp.ini /etc/xrdp/xrdp.ini.griffon
#Check where to copy the logo file
if [ -d "/usr/local/share/xrdp" ] 
then
    echo
    sudo cp griffon_logo_xrdp.bmp /usr/local/share/xrdp
    sudo sed -i 's/ls_logo_filename=/ls_logo_filename=\/usr\/local\/share\/xrdp\/griffon_logo_xrdp.bmp/g' /etc/xrdp/xrdp.ini
else
    sudo cp griffon_logo_xrdp.bmp /usr/share/xrdp
    sudo sed -i 's/ls_logo_filename=/ls_logo_filename=\/usr\/share\/xrdp\/griffon_logo_xrdp.bmp/g' /etc/xrdp/xrdp.ini
fi

sudo sed -i 's/blue=009cb5/blue=dedede/' /etc/xrdp/xrdp.ini
sudo sed -i 's/#white=ffffff/white=dedede/' /etc/xrdp/xrdp.ini
sudo sed -i 's/#ls_title=My Login Title/ls_title=Remote Desktop for Linux/' /etc/xrdp/xrdp.ini
sudo sed -i 's/ls_top_window_bg_color=009cb5/ls_top_window_bg_color=4F194C/' /etc/xrdp/xrdp.ini
sudo sed -i 's/ls_bg_color=dedede/ls_bg_color=ffffff/' /etc/xrdp/xrdp.ini
sudo sed -i 's/ls_logo_x_pos=55/ls_logo_x_pos=0/' /etc/xrdp/xrdp.ini
sudo sed -i 's/ls_logo_y_pos=50/ls_logo_y_pos=5/' /etc/xrdp/xrdp.ini
}

#---------------------------------------------------#
# Function 6 - Fix SSL Minor Issue .... 
#---------------------------------------------------#

fix_ssl() 
{ 
echo 
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m" 
/bin/echo -e "\e[1;33m   ! Fixing SSL Cert Issue ...                   !\e[0m" 
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m" 
echo 
if id -Gn xrdp | grep ssl-cert 
then 
/bin/echo -e "\e[1;32m   !--xrdp already member ssl-cert...Skipping ---!\e[0m" 
else
    sudo adduser xrdp ssl-cert 
fi
}

#---------------------------------------------------#
# Function 7 - Fixing env variables in XRDP .... 
#---------------------------------------------------#

fix_env()
{
#Add this line to /etc/pam.d/xrdp-sesman if not present
if grep -Fxq "session required pam_env.so readenv=1 user_readenv=0" /etc/pam.d/xrdp-sesman 
   then
            echo "Env settings already set"
   else
        sudo sed -i '1 a session required pam_env.so readenv=1 user_readenv=0' /etc/pam.d/xrdp-sesman
 fi
}
#---------------------------------------------------#
# Function 8 - Removing XRDP Packages .... 
#---------------------------------------------------#

remove_xrdp()
{
echo 
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m" 
/bin/echo -e "\e[1;33m   ! Removing xRDP Packages...                   !\e[0m" 
/bin/echo -e "\e[1;33m   !---------------------------------------------!\e[0m" 
echo 

#remove the xrdplog file created by the script 
sudo rm /etc/xrdp/xrdp-installer-check.log
#----remove xrdp package
sudo systemctl stop xrdp
sudo systemctl disable xrdp
sudo apt-get autoremove xrdp -y
sudo apt-get purge xrdp -y

#---remove xorgxrdp
sudo systemctl stop xorgxrdp
sudo systemctl disable xorgxrdp
if [[ $HWE = "yes" ]] && [[ "$version" = *"Ubuntu 18.04"* ]];
then
    sudo apt-get autoremove xorgxrdp-hwe-18.04 -y 
    sudo apt-get purge xorgxrdp-hwe-18.04 -y
else
    sudo apt-get autoremove xorgxrdp -y 
    sudo apt-get purge xorgxrdp -y
fi

#---Cleanup files 
#Remove xrdp folder
if [ -d "$Dwnload/xrdp" ] 
then
    sudo rm -rf xrdp
fi
#Remove xorgxrdp folder
if [ -d "$Dwnload/xorgxrdp" ] 
then
    sudo rm -rf xorgxrdp
fi

#Remove custom xrdp logo file
if [ -f "$Dwnload/griffon_logo_xrdp.bmp" ]
then
    sudo rm -f  "$Dwnload/griffon_logo_xrdp.bmp"
fi
sudo systemctl daemon-reload
}

sh_credits()

{

echo
/bin/echo -e "\e[1;36m   !----------------------------------------------------------------!\e[0m"
/bin/echo -e "\e[1;36m   ! Installation Completed...Please test your xRDP configuration   !\e[0m" 
/bin/echo -e "\e[1;36m   ! If Sound option selected, shutdown your machine completely     !\e[0m"
/bin/echo -e "\e[1;36m   ! start it again to have sound working as expected               !\e[0m"
/bin/echo -e "\e[1;36m   !                                                                !\e[0m"
/bin/echo -e "\e[1;36m   ! Credits : Written by Griffon - Dec. 2020                       !\e[0m"
/bin/echo -e "\e[1;36m   !           www.c-nergy.be -xrdp-installer-v$ScriptVer.sh             !\e[0m"
/bin/echo -e "\e[1;36m   !           ver $ScriptVer                                            !\e[0m"
/bin/echo -e "\e[1;36m   !----------------------------------------------------------------!\e[0m"
echo
}

#---------------------------------------------------#
# SECTION FOR OPTIMIZING CODE USAGE...              #
#---------------------------------------------------#

install_common()
{
allow_console
create_polkit
fix_theme
fix_ssl
fix_env
}

install_custom()
{
install_prereqs
get_binaries
compile_source
enable_service
}

#--------------------------------------------------------------------------#
# -----------------------END Function Section             -----------------#
#--------------------------------------------------------------------------#
#--------------------------------------------------------------------------#
#------------                 MAIN SCRIPT SECTION       -------------------# 
#--------------------------------------------------------------------------#
#---------------------------------------------------#
# Script Version information Displayed              #
#---------------------------------------------------#

#--Automating Script versioning 
ScriptVer="1.2.3"
echo
/bin/echo -e "\e[1;36m   !---------------------------------------------------------------!\e[0m"
/bin/echo -e "\e[1;36m   !   xrdp-installer-$ScriptVer Script                                 !\e[0m"
/bin/echo -e "\e[1;36m   !   Support 18.04/20.04/20.10/21.04                             !\e[0m"
/bin/echo -e "\e[1;36m   !   Written by Griffon - Nov 2020 - www.c-nergy.be              !\e[0m"
/bin/echo -e "\e[1;36m   !                                                               !\e[0m"
/bin/echo -e "\e[1;36m   !   For Help and Syntax, type ./xrdp-installer-$ScriptVer.sh -h      !\e[0m"
/bin/echo -e "\e[1;36m   !                                                               !\e[0m"
/bin/echo -e "\e[1;36m   !---------------------------------------------------------------!\e[0m"
echo
#----------------------------------------------------------#
# Step 0 -Detecting if Parameters passed to script ....    #
#----------------------------------------------------------#

for arg in "$@"
do
    #Help Menu Requested
    if [ "$arg" == "--help" ] || [ "$arg" == "-h" ]
    then
                echo "Usage Syntax and Examples"
                echo
                echo " --custom or -c           custom xRDP install (compilation from sources)"
        echo " --loginscreen or -l      customize xRDP login screen"
                echo " --remove or -r           removing xRDP packages"
                echo " --sound or -s            enable sound redirection in xRDP"
                echo
                echo "example                                                      "
                echo     
                echo " ./xrdp-installer-$ScriptVer.sh -c -s  custom install with sound redirection"
                echo " ./xrdp-installer-$ScriptVer.sh -l     standard install with custom login screen"
                echo " ./xrdp-installer-$ScriptVer.sh        standard install no additional features"
                echo
                exit
    fi

    if [ "$arg" == "--sound" ] || [ "$arg" == "-s" ]
    then
        fixSound="yes"              
    fi 

    if [ "$arg" == "--loginscreen" ] || [ "$arg" == "-l" ]
    then
        fixlogin="yes"
    fi

    if [ "$arg" == "--custom" ] || [ "$arg" == "-c" ]
    then
        adv="yes"   
    fi
    if [ "$arg" == "--remove" ] || [ "$arg" == "-r" ]
    then
        removal="yes"       
    fi
done

#--------------------------------------------------------------------------------#
#-- Step 0 - Check that the script is run as normal user and not as root....
#-------------------------------------------------------------------------------#

if [[ $EUID -ne 0 ]]; then
    /bin/echo -e "\e[1;36m   !-------------------------------------------------------------!\e[0m"
    /bin/echo -e "\e[1;36m   !  Standard user detected....Proceeding....                   !\e[0m"
    /bin/echo -e "\e[1;36m   !-------------------------------------------------------------!\e[0m"
else
    echo
    /bin/echo -e "\e[1;31m   !-------------------------------------------------------------!\e[0m"
    /bin/echo -e "\e[1;31m   !  Script launched with sudo command. Script will not run...  !\e[0m"
    /bin/echo -e "\e[1;31m   !  Run script a standard user account (no sudo). When needed  !\e[0m"
    /bin/echo -e "\e[1;31m   !  script will be prompted for password during execution      !\e[0m"
    /bin/echo -e "\e[1;31m   !                                                             !\e[0m"
    /bin/echo -e "\e[1;31m   !  Exiting Script - No Install Performed !!!                  !\e[0m"
    /bin/echo -e "\e[1;31m   !-------------------------------------------------------------!\e[0m"
    echo
    #sh_credits
    exit
fi

#---------------------------------------------------#
#-- Step 1 - Try to Detect Ubuntu Version....
#---------------------------------------------------#

version=$(lsb_release -sd)
codename=$(lsb_release -sc)
echo
/bin/echo -e "\e[1;33m   |-| Detecting Ubuntu version        \e[0m"

if  [[ "$version" = *"Ubuntu 18.04"* ]];
then
    /bin/echo -e "\e[1;32m       |-| Ubuntu Version : $version\e[0m"
    echo
elif [[ "$version" = *"Ubuntu 20.04"* ]];
then
    /bin/echo -e "\e[1;32m       |-| Ubuntu Version : $version\e[0m"
    echo
elif [[ "$version" = *"Ubuntu 20.10"* ]];
then
    /bin/echo -e "\e[1;32m       |-| Ubuntu Version : $version\e[0m"
    echo
elif [[ "$version" = *"Ubuntu 21.04"* ]];
then
    /bin/echo -e "\e[1;32m       |-| Ubuntu Version : $version\e[0m"
    echo
else
   /bin/echo -e "\e[1;31m  !--------------------------------------------------------------!\e[0m"
   /bin/echo -e "\e[1;31m  ! Your system is not running a supported version               !\e[0m"
   /bin/echo -e "\e[1;31m  ! The script has been tested only on the following versions    !\e[0m"
   /bin/echo -e "\e[1;31m  ! 18.04.x/20.04.10/20.10/21.04                                 !\e[0m"
   /bin/echo -e "\e[1;31m  ! The script is exiting...                                     !\e[0m"             
   /bin/echo -e "\e[1;31m  !--------------------------------------------------------------!\e[0m"
   echo
   exit
fi

#-----------------------------------------------------------------------
#Step 2 - checking for additional Settings - xorg-xserver-core version
#----------------------------------------------------------------------
check_hwe
#--------------------------------------------------------------------------------#
#-- Step 3 - Check if Removal Option Selected
#--------------------------------------------------------------------------------#
if [ "$removal" = "yes" ];
then
    remove_xrdp
    echo
    sh_credits
    exit
fi

#---------------------------------------------------------#
# Step 4 - Executing the installation & config tasks .... #
#---------------------------------------------------------#

#Check if script has run once...
if [ -f /etc/xrdp/xrdp-installer-check.log ]
then
echo
/bin/echo -e "\e[1;36m   !----------------------------------------------------------------!\e[0m"
/bin/echo -e "\e[1;36m   ! INFO : xrdp-install script ran at least once on this computer. !\e[0m" 
/bin/echo -e "\e[1;36m   !----------------------------------------------------------------!\e[0m"
fi

if [ "$adv" = "yes" ];
then
       echo
        /bin/echo -e "\e[1;36m   !-------------------------------------------------------------!\e[0m"
        /bin/echo -e "\e[1;36m   !  Custom Installation Option Selected.....                   !\e[0m"
        /bin/echo -e "\e[1;36m   !-------------------------------------------------------------!\e[0m"
        echo
        install_custom
        install_tweak
        install_common     
else
        echo
        /bin/echo -e "\e[1;36m   !-------------------------------------------------------------!\e[0m"
        /bin/echo -e "\e[1;36m   !  Standard Installation Mode Selected - U18.04 and later     !\e[0m"
        /bin/echo -e "\e[1;36m   !-------------------------------------------------------------!\e[0m"
        echo
        install_xrdp
        install_tweak
        install_common
fi  #end if Adv option

#---------------------------------------------------------------------------------------
#- Check for Additional Options selected 
#----------------------------------------------------------------------------------------

if [ "$fixSound" = "yes" ]; 
then 
        enable_sound      
fi

if [ "$fixlogin" = "yes" ]; 
then
    echo
    custom_login
fi

#-----------------------------------------------------------------------
# Create Check file to see if script has run at least once...
#----------------------------------------------------------------------

#Create the log file 
sudo touch /etc/xrdp/xrdp-installer-check.log

#---------------------------------------------------------------------------------------
#- show Credits and finishing script
#--------------------------------------------------------------------------------------- 
sh_credits 





59 thoughts on “xRDP – Easy install xRDP on Ubuntu 18.04,20.04,20.10,21.04 (Script Version 1.2.3)

  1. Awesome job.
    For ubuntu 20 minimal with the sound enabled I needed `sudo apt-get install libconfig-dev -y` else “config.h: No such file or directory” xD
    Notice the link in wget needs to be corrected:
    from: c-nergy.be/downloads/xrdp-installer-1.2.3.zip
    to: c-nergy.be/downloads/xRDP/xrdp-installer-1.2.3.zip

  2. @Stawiu,

    Thank you for visiting our blog and sharing your findings… We will try to update the script to include your findings and we will update the post. You are totally right, the download location has been changed… The post has been updated and reflect the correct location now

    Thank for your support
    Till next time
    See ya

  3. With Ubuntu 21.04, I can successfully login once from a Mac or Windows remote desktop client. The second time I login, it gives me a black screen. How do I debug this issue?

  4. @HMW,

    We have not encountered this issue. We are able to logout from the remote session against Ubuntu 21.04 and reconnect. We are also able to disconnect our session and go back to the session where we left it….
    Usually, the black screen issue is due to the fact that the user account you are using is already logged into the machine (local session). You can check this post for more info (see https://c-nergy.be/blog/?p=16682

    If this is not your issue, maybe can you explain your sequence when login/logout/disconnect/reconnect to better understand your issue ?

    waiting for your feedback
    Till next time
    See ya

  5. @Griffon

    I have two VMs, one running Ubuntu 20.04 LTS and using xrdp-installer-1.2 and the other running 21.04 with either xrdp-installer-1.2.2 or 1.2.3

    With the VM running 20.04 I can connect and disconnect the session and log back in. I have seen the black screen before when I’ve already logged in but it usually also gives me the xrdp login screen as well.

    With the VM running 21.04, I can connect ONCE – the second time I disconnect it wont reconnect to the session. I fixed the issue by removing the installer script, manually installing sudo apt install xrdp and then checking /etc/X11/Xwrapper.config for access to everybody, checking the correct entries for polkit and finally checking if xrdp was a member of ssl-cert. When I started the service it asked me to authenticate and it’s been working since (so disconnecting and reconnecting works)

    I have no idea why it wouldn’t work for 21.04 but at least the script shows me what all to do albeit manually …

  6. @HMV,

    Thank you for the feedback. At least it seems that you have kind of solved your issue…As you mentioned, this is really strange because basically the script is simply running in sequence commands you would type manually.
    Have you try to enable the multi session trick ? (see https://c-nergy.be/blog/?p=16698) we do not recommend it but this could help investigate further the issue. It also happens that if you logoff from console and try quickly to remote login to end up in a limbo scenario
    We will perform some additional testing.. are you connecting from Windows box or a Mac box ? So we can try to replicate the issue

    Till next time
    See ya

  7. The current 21.04 Ubuntu (for ARM64) is unable to install xrdp via the sources due to the following error: “configure: error: please install libpam0g-dev or pam-devel”. When trying to install the libpam0g-dev I’m getting this error:

    “The following packages have unmet dependencies:
    libpam0g-dev : Depends: libpam0g (= 1.3.1-5ubuntu6.21.04.1) but 1.3.1-5ubuntu6 is to be installed”

    This used to work just fine 1-2 weeks ago :-/

  8. @SNC,

    Thanks for visiting our blog and providing feedback and sharing your findings…. We do not really use arm64 version so we are not really sure would could be the problem here…
    Based on the message, you have unmet dependencies… to install libpam0g-dev you would need to install libpam0g first…. Can you give it a try…. ?
    ensure that you have also performed a sudo apt-get update to be sure that latest packages and source list are up to date

    Hope this help
    Till next time
    see ya

  9. @max2veg,

    We are planning to publish an preview version of our xrdp installer script in the next two weeks. This script is marked as preview because we are trying to add more OS distribution but we have not fully tested it.
    The script will work against Ubuntu, Pop!OS, Debian and the script will also try to detect the Desktop interface which means that in theory the script could be runn against other Ubuntu flavors like Kubuntu and maybe more….

    If you have time to test and provide feedback for the pop!os part, that would be great 🙂

    Till next time
    See ya

  10. @Donald,

    The script would run on Ubuntu Server. However, since you want to use xRDP, we assume that you would have already installed on top of your Ubuntu Server a Desktop interface and more specifically Gnome Desktop. A new version of the script is being worked out which might allow to support more desktop interfaces

    Hope this answer your question

    Till next time
    See ya

  11. I love this script for installing xRDP on my Ubuntu 20.04 installation – as I find it much easier to access and use the 27″ monitor, real keyboard and mouse. My one complaint is that when I install this – it does funky things to the Bluetooth (USB adapter) which is seen and I can utilize from the SYSTEM SETTINGS area with no problems. After installing this script – it always shows Bluetooth Not Found. I also find that I cannot use gedit or TimeShift over xRDP connections. I also find that Sound Redirection does not work unless (while RDP into the laptop – I open terminal and type ‘pulseaudio -k’ – Then the Dummy Device becomes xrpd sink (and I have sound again).

  12. @Curtis;

    Thank you for visiting our blog and providing feedback. As we are not using bluebooth devices on your test lab; we never encountered the issue you are mentioning. Possibly, could you provide us some screenshots so we could assess what could be the problem. it might be caused by polkit policy within your xRDP session. The script should not affect the gedit functinonality.. We are using all the time gedit over xrdp sessions. Can you again provide some information/details, which kind of issues are you encountering, gedit cannot be opened; you cannot save stuff ?

    Finally, about the sound redirection, this is a known issue and indeed the pulseaudio -k is the workaround we are recommending in order to fix this recurring issue

    So if possible share some more details about the bluetooth,gedit and timeshift issue
    Till next time
    See ya

  13. Maybe add apt install software-properties-common and sudo apt-get install libconfig-dev -y to the config, for the Persons, that are going to install the Script in an LXC Container on Proxmox.

    Best Regards.

  14. Griffon says:
    June 19, 2021 at 2:24 pm
    @max2veg,
    We are planning to publish an preview version of our xrdp installer script in the next two weeks.

    @Griffon: Any update on it? No rush, just wondering.

  15. @Calvin,

    Thank you for visiting our blog and providing feedback… As we are working on a more generic script (check this link https://c-nergy.be/blog/?p=16703), we will see if we can integrate this feature in the script.. Might take some time as we are overloaded with work at the moment…

    Till next time
    See ya

  16. I use xRDP with your great script for connecting to Ubuntu 20.04 LTS running as a locally deployed Hyper-V guest and need to connect to a Cisco AnyConnect based VPN from this VM. Actually I use openconnect + openconnect network manager integration for this. Since updating to some newer version of systemd stuff by regular updates (since spring 2021 or so; I did some error cause isolation tests on this) the VPN connection does not work any more. I have the same VPN setup on a natively installed Ubuntu 20.04 LTS machine (no VM there, no xRDP since no need for this), and there it works. Rolling back to an older backup of the VM’s image also shows that there is no problem with the config or remote: VPN works again. Do you have any idea what the cause of this defect may be?

  17. @CGI,

    Thank you for visiting our blog and sharing your findings… We do not really know what could be the problem…but we would guess that the updates might have created conflicts in some packages. You could try the following. either complete delete your vpn profile and recreate it and test it or more drastic approach remove and re-install your open vpcn client software on it. Please do a proper snapshot before proceeded…

    Hope this help
    Till next time
    See ya

  18. Just to drop a state: Removing and re-adding openconnect (with shutdown & boot inbetween of course) did not change anything. Since there is nothing like a “profile” when using openconnect from CLI no profile operations where in question. I gave updating the kernel a try (from 5.4 via 5.8 to 5.13) but that also did not change anything. — However I do not see any “cause” by xrdp or so, but I simply hoped that you may have heard about similar issues. Actually it simply seems to be a very rare edge case…

  19. @CGI,

    thanks for sharing your experience with us. After some discussion with you, it turned out that the issue was more a systemd issue. Based on the feedback and info you have provided, a recent update for systemd has fix the issue
    Till next time
    See ya

  20. You can add this after line 374 in the script for the sound redirection:

    sudo sed -i “s/Exec=start-pulseaudio-x11/Exec=pulseaudio -k/” /etc/xdg/autostart/pulseaudio.desktop

  21. @Danny,

    Thank you for visiting our blog and sharing your findings… Yes, we know we could update the autostart file or add a startup script or use the pulseaudio -k into the .xsessionrc. However, so far all these approaches have resulted in inconsistent behavior. Sometimes sound card is detected sometimes we still need to perform the operation manually….We are trying to work on this issue and try to find the best and consistent way to get xrdp sink card loaded at login….

    Till next time
    See ya

  22. Hello Griffon, I also get a blank black screen on Ubuntu 20.04, however, I can only see the mouse cursor and no terminal prompt. This is with ver 1.2.3 and no errors on install.

    I do have the included Ubuntu Gnome Desktop installed and I can VNC, SSH, and Chrome Remote Desktop fine.

    Anything you can suggest to troubleshoot this? The PC is hooked up to a 4k TV so VNC is unusable because it has the bug of only showing the top left corner.

  23. @Justin,

    thank you for visiting our blog and sharing your findings….Based on your description, we would guess that you are trying to login through xrdp using the same user account that’s currently logged on on your system locally. As mentioned in the post, this is not supported. You can configure your system to have the same account logged on locally and remotely but we do not recommend this approach as other side effects might show up… You can find instructions on how to perform such configuration by visiting this post (https://c-nergy.be/blog/?p=16698)

    Hope this help
    Till next time
    See ya

  24. Hi,
    After run the script and reboot computer(Ubuntu 20.04), I want to access Ubuntu via mstsc(Windows 10), but it show “Oh no! Something has gone wrong. A problem has occurred and the system can’t recover. Please log out and try again”.
    How to solve this issue?

  25. @Wang Yu,

    Thank you for visiting our blog and sharing your findings….First things first,

    – which version of Ubuntu 20.04 are you using ?
    – are you using the Ubuntu Desktop version ?
    – which release point (lsb_release -a) ? is the latest version 20.04.3 ?
    – Are you using the Gdm3 Desktop ?
    – Are you logged in locally on the system and you are trying to login remotely using exactly the same user ?
    – have you done a standard installation or have you used the custom installation mode ?
    – which version of xrdp are you running ? (xrdp -v)

    So, this problem is due to the fact that the desktop is not loading properly within your remote desktop session… or that you are using a non GDM3 Ubuntu Desktop or that something is indeed wrong…..

    To investigate further, you have to first look at the logs (/var/log/xrdp.log and /var/log/xrdp-sesman.log, check also ~/.xsession-errors)

    You have to check also that you have a file created under ~/.xsessionrc exists and has been created for the user account that tries to login into the system via remote desktop. The content of the file should be something like

    export GNOME_SHELL_SESSION_MODE=ubuntu
    export XDG_CURRENT_DESKTOP=ubuntu:GNOME
    export XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg

    This file is re-created every time you login into your system via remote desktop session

    You can try to remove the xrdp package (using the script via the option ./xrdp-installer-xxx.sh -r ) and try to re-install it manually and see if this would work… Pay attention to the screen when perform the manual installation to see if there is no errors thrown at the console

    Hope this help
    Waiting for your feedback
    Till next time
    See ya

  26. THANK YOU, THANK YOU, THANK YOU!
    Ubuntu Desktop 18.04.6 (latest) on Dell E6330 laptop.
    I can FINALLY remote from my Windows 10 into this machine.
    I have tried 3 versions of Ubuntu (18, 20, 21) and so many RDP / XRPD solutions and none of them have worked. Literally spent 8 solid hours on this.
    I used this script with -l and -s.
    I think I may skip the sound next because I never need sound from that machine.

  27. @Sam,

    Thank you for visiting our blog and providing such a positive feedback… Thank you for your feedback we are really happy to see that we can provide some helpful information out there
    We hope we will enjoy your remote session experience and that you will enjoy also Ubuntu OS 🙂

    Till next time
    See ya

  28. Why does Gnome Extensions not work after using your script?

    Remote desktop works fine, but I cannot install Dash to Panel gnome extension. I installed the Firefox gnome extension thing, and then tried to toggle the Dash to Panel extension to on position, but it just reverts back to off on refresh of the page and doesn’t install the extension.

    On my other machine (both are 20.04 Ubuntu) installing gnome extensions work fine, but on that machine I installed xrdp manually and not using this script.

    Otherwise they are identical machines.

    Thanks for the great work tho!

  29. I am a total linux noob, and while I have ubuntu 20.04 running fine, when I tried to run the script to fix the xrdp issues (the color profile issue), once I tried running the script, the system behavior changes.

    before I run the script, if I go to my users under settings, I can click on the unlock button to change settings for a user. once I try running the script, i’ve clearly done something wrong/incomplete, as I can no longer click that unlock button.

    I do have one other Ubuntu system which i have not had issues with (but i cannot remember if I built it and used the script, or fixed the color profile issue some other way).
    Wondering if this is something you’ve seen/heard before and if so, is it an easy fix because I made a stupid mistake? The last two times, since there was not much on the sysem, I just re-imaged it. I can again, but i will end up in the same spot again, where I need to fix my xrdp.
    for now, the system seems fine enough, but when i remote in, i always get a system error popup (asks if i want to report it, but never shows me the details anymore). when i looked at the log, it was an xrdp crash of some variety, i can paste that if it helps.

    hoping this is an easy fix

    thanks!

  30. @Jmd,

    Thank you for visiting our blog and providing feedback. The problem you described is actually by design. Ubuntu use Polkit technology in order to harden and protect your system from unwanted actions and activities. Polkit settings are different when connected locally on the machine and when connected remotely through xRDP. You can find more information reading the following two posts we have published some time ago

    To enable User Administration within the Remote session, you will need to create a additoinal .pkla file (which will override polkit restrictions).
    to create this additional file, you can use the following command

    sudo bash -c “cat >/etc/polkit-1/localauthority/50-local.d/46-user-admin.pkla” <

    Hope this help
    Till next time
    See ya

  31. @Juusto,

    Thank you for visiting our blog and providing feedback. The script does not change the system behavior. The script simply install and configure the xRDP package….Have you tried to perform the configuration change first when you locally logged on (not when your are performing the remote desktop connection).. is this working ? Have you disabled the Ubuntu Dock extension in order to use Dash to Pane and avoid some conflicts. ..Do you know that you can move the Ubuntu Dock to bottom as well… we will have a look into this but again we do not think that the script is causing the issue per se

    Updated : We have tested the process on Ubuntu 21.10….We do not see the problem or we cannot recreate the situation…We have run the xrdp script and from the remote session, we have been able to enable gnome extensions….

    Maybe you can share a screenshot of what you see ?

    Hope this help
    Till next time
    See ya

  32. Thanks for the reply. I think I understand the restrictions, but what I was seeing is (i think) because i screwed up the script.

    Things that worked before no longer worked (local account, not remote, could no longer unlock users to edit them, could not reboot using the GUI, only CLI). And, when I would turn on the instance and get started, I would get a system error message, and while i could click cancel or report, i would not see what actually had an issue unless i went to the logs.
    after re-imaging a few times, I know this only happened once I attempted to make use of the script, so i am pretty sure i didn’t execute it fully somehow.

  33. @Shad,

    Thank you for visiting our blog and providing feedback. We are happy to see that the script is still useful and we will try to keep updating it. Good to see also that more and more people are willing to work with Ubuntu and Linux…

    Till next time
    See ya

  34. @Jmd,

    Thank you for your feedback…. Again, we do not think the script would interfere with your local experience. The script is just a suite of commands that basically
    – install a package (xrdpd and xorgxrdp)
    – ensure that polkit will not show you some popups when you login via remote session
    – ensure that the desktop your are using when locally connected will be replicated into your remote session
    – and finally if you select the option, will install additional sound module to allow sound redirection

    Apart from that, the script is not changing any major settings on the system itself… You can edit the script and you will see indeed that really minor changes are performed by the script

    Hope this help

    Till next time
    See ya

  35. Hello I Installed the program and it was ok
    Installation Completed…………..

    But I have the same problem
    Conecting to sesman……..ip 127.0.0.1 port 3350…

  36. hello all,

    I have the Kubuntu 20.04 LTS and tried installing this. However it didnt’ work for me. I used the command below to run my install which says sound redirect enabled:

    ./xrdp-installer-1.2.3.sh -s

    It installed everything successfully, and then I rebooted my machine. When I tried to RDP using Windows 10 and followed the exact same configuration, it would take me to the XRDP login, and the moment I enter my userid and password, it tries to connect and then takes me back to the Windows 10 Remote Desktop. Nada.

    Don’t know why it would do that. It just won’t even let me RDP anymore. Just frustrated at the moment.

  37. @John,

    Thank you for visiting our blog and providing feedback…
    The behavior you have might be expected…. Version 1.2.3 of the script does not support Kubuntu…This is mentioned specifically in the post…Check Prerequisites and assumptions section. This script is targeting Standard Ubuntu systems and no other flavors like Kubuntu, Lubuntu…or any other ones…..

    However, you are lucking since we have released recently a new version of the script (version 1.3) which should be able to configure your system accordingly and have your Kubuntu session presented to you via remote desktop….
    So, what I would recommend…use our script to uninstall the xrdp installation (xrdp-installer-1.2.3.sh -r) and try to run the version 1.3 of the script… Please read the following post (https://c-nergy.be/blog/?p=17175 and give it a try

    Hope this help
    Till next time
    See ya

  38. I’ve been fighting a problem between Guacamole and xRDP for a couple weeks where Drive Redirection was failing.

    If I used FreeRDP I had no problem with Drive Redirection.

    The xRDP I use is created with C-Energy’s script.

    Finally, sent an email to the Guacamole User group and Mike responded alerting me of a Bug in xRDP where he indicates is fixed in a new Release.

    https://lists.apache.org/thread/s99rf1zl1hrtfoqg6zkrvbl9ccb0zoj8

    Just wanted to let you know in case you hadn’t seen this yet.

  39. @Brian,

    Thank you for your feedback Brian :). Yes, we know that there are some issues with package version 0.9.12. The issue you mentioned; we were not aware and it’s good that you have notified us.
    For any other users that might have some concerns with this specific issue, please note that our script can be used also to compile directly from sources files . If you do this, you would be running version 0.9.17 and the problem should not be there

    Thanks again for sharing
    Till next time
    See ya

  40. @David Chang,

    Thank you for visiting our blog and providing feedback. Please note that the latest version of the script (i.e. version 1.3) includes support for Ubuntu 21.10
    You can find the latest version of the script at http://www.c-nergy.be/products.html and/or you can find detailed instructions and the script on this post (see xRDP – Easy install xRDP on Ubuntu 18.04,20.04,21.04,21.10 (Script Version 1.3). We have also updated the old post to mention that a new version of the script is available

    Hope this help
    Till next time
    See ya

  41. In the script
    is the command line parameter “-l” still valid to use?
    When I use the 3 parameters “-c -l -s”
    My script spits out an eror that “-l” is not valid.

  42. @Brian,

    Thank you for providing some feedback… First, please note that there is a newer version of the script (1.3) that has been made available. Second, the -l is indeed still a valid option… Instead of using -l, can you try to use the full syntax –loginscreen -c -s and see if it get better. If not, can you provide us a screenshot of the error (or error message, line error…so we can check this )

    Alternatively, can you try the latest version of the script and see if this fix your issue.

    Hope this help
    Till next time
    See ya

  43. Good morning,

    I noticed that if you RDP into a server from 2 different computers you will end up with 2 different RDP sessions.

    how can I RDP into a server from computer A and then RDP into the same server from computer B and reconnect to same RDP session as computer A.

    Thank you for your help

Leave a Reply