xRDP – Install xRDP the easy way on Ubuntu 18.04.x and 19.04 (Scripted Installation – Version 0.6.1)

Hello World, 

This post will be quite short.  Based on some users comments and feedback, we have detected a small issue with our famous script to perform a standard xRDP installation on Ubuntu 18.04.3 specifically.   After a quick investigation, we have found the issue and we have fixed it.  The question was for us to either update the script and not changing the numbering or update the script and change the numbering.  We decided to change the numbering in order to bring awareness  with this issue.   The change is really minor.  We have modified the logic that used to check Ubuntu 18.04.x version.   The version 0.6 of the script would not perform the correct action if you are running it on Ubuntu 18.04.3 version.   The script would work up to Ubuntu 18.04.2 version as the logic detect this correctly and will apply the proper fix.  The problem is related to the fact that Ubuntu 18.04.2 is relying on xorg-xserver-core-hw* libraries which cannot be used when using the xrdp package stored in Ubuntu repositories.   You can real the full story here.

Overview

Ubuntu 18.04.2 and later are relying on xorg-xserver-core-hw* packages that are incompatible with the xrdp packaged provided by Ubuntu.  When you try to perform a manual installation of xrdp package on Ubuntu 18.04.2 or 18.04.3, the installation of xorgserver package will fail because it relies on the xorg-xerver-core* packages.  The script version 0.6 was taking into account this issue only up to Ubuntu 18.04.2.  We thought that Canonical would have fixed this issue in the latest Point release 18.04.3.  Actually, this is not the case and the issue still remains.  Because of this, we have performed a minor update on the Standard installation script in order to include Point release 18.04.3 (and probably later versions of Point releases) 

Prerequisites and assumptions

We assume that you have internet connection available and that you are indeed running one of the following version of Ubuntu 

  • Ubuntu 18.04 (up to Ubuntu 18.04.3)
  • Ubuntu 18.10
  • Ubuntu 19.04 
  • We have performed the test on a Virtual Machine running on Virtual box (on Windows 2012 R2) with Sound enabled !!!
  • No additional Desktop interface will be used. The remote desktop session will display the Ubuntu tweak Gnome Desktop interface

The script version 0.6.1

Important Note :

If you copy/paste the script, you might encounter some issues because font formatting might be not maintained during the copy/paste operation. Please ensure that format is  accurate before launching the script. A downloadable version of the script is available at the bottom of the post

Disclaimer : As usual, use this at your own risk !!

#!/bin/bash
#####################################################################################################
# Script_Name : Std-Xrdp-install-0.6.1.sh
# Description : Perform an automated standard installation of xrdp
# on ubuntu 18.04 and later
# Date : Sept 2019
# written by : Griffon
# Web Site :http://www.c-nergy.be - http://www.c-nergy.be/blog
# Version : 0.6.1
# History : 0.6.1 - Added support for Ubuntu 18.04.3 
#         : 0.6   - Added support for Ubuntu 19.04 
#                 - New code for Look'n feel using xsessionrc method
#                 - New code for enabling Sound Redirection - compiling from source 
#                 - Removed -g parameter 
#         : 0.5.3 - Using Unoffical xRDP packages for Ubuntu 18.04.2 issue
#         : 0.5.2 - Quick Fix for Ubuntu 18.04.2
#         : 0.5.1 - Add support to Ubuntu 18.10 
#         : 0.5 - Add logic to enable sound redirection 
#               - re-write code logic to include functions
#               - Removed support for Ubuntu 17.10 as reached end of support
#         : 0.4 - Add logic to fix GDM lock screen + minor change
#         : 0.3 - Adding logic to fix theme and extensions for any users login through xrdp
#           0.2 - Added Logic for Ubuntu 17.10 and 18.04 detection 
#              - Updated the polkit section
#              - New formatting and structure 
#         : 0.1 - Initial Script 
# Disclaimer : Script provided AS IS. Use it at your own risk....
####################################################################################################
#---------------------------------------------------#
# Detecting if Parameters passed to script .... 
#---------------------------------------------------#

while getopts s:u: option 
do 
case "${option}" 
in 
s) fixSound=${OPTARG};;
u) unofficialRepo=${OPTARG};; 
esac 
done

#---------------------------------------------------#
# Script Version information Displayed #
#---------------------------------------------------#

echo
/bin/echo -e "\e[1;36m !-------------------------------------------------------------!\e[0m"
/bin/echo -e "\e[1;36m ! Standard XRDP Installation Script - Ver 0.6.1                 !\e[0m"
/bin/echo -e "\e[1;36m ! Written by Griffon - Sept 2019 - www.c-nergy.be              !\e[0m"
/bin/echo -e "\e[1;36m !-------------------------------------------------------------!\e[0m"
echo

#--------------------------------------------------------------------------#
# -----------------------Function Section - DO NOT MODIFY -----------------#
#--------------------------------------------------------------------------#

#-----------------------------------------------------#
# Function 0 - Quick and Dirty Patch Ubuntu 18.04.x   #
#-----------------------------------------------------#

install_xservercore() 
{
echo
/bin/echo -e "\e[1;33m !----------------------------------------------------------!\e[0m"
/bin/echo -e "\e[1;33m ! Installing xserver-xorg-core Packages...Proceeding... !\e[0m"
/bin/echo -e "\e[1;33m !----------------------------------------------------------!\e[0m"
echo
sudo apt-get install xserver-xorg-core -y
echo
/bin/echo -e "\e[1;33m !----------------------------------------------------------!\e[0m"
/bin/echo -e "\e[1;33m ! Installing xserver-xorg-input-all pkg...Proceeding... !\e[0m"
/bin/echo -e "\e[1;33m !----------------------------------------------------------!\e[0m"
echo
sudo apt-get -y install xserver-xorg-input-all 
}

#---------------------------------------------------#
# Function 1 - 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
sudo apt-get install xrdp -y 
}

#---------------------------------------------------#
# Function 2 - 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 3 - 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 4 - 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

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

[Allow Package Management all Users]
Identity=unix-user:*
Action=org.debian.apt.*;io.snapcraft.*;org.freedesktop.packagekit.*;com.ubuntu.update-notifier.*
ResultAny=no
ResultInactive=no
ResultActive=yes
EOF

}

#---------------------------------------------------#
# Function 5 - 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"
echo
sudo sed -i.bak "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 6 - 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 'deb http://be.archive.ubuntu.com/ubuntu/ '$codename' main restricted'
sudo apt-add-repository -s 'deb http://be.archive.ubuntu.com/ubuntu/ '$codename' restricted universe main multiverse'
sudo apt-add-repository -s 'deb http://be.archive.ubuntu.com/ubuntu/ '$codename'-updates restricted universe main multiverse'
sudo apt-add-repository -s 'deb http://be.archive.ubuntu.com/ubuntu/ '$codename'-backports main restricted universe multiverse'
sudo apt-add-repository -s 'deb http://be.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 -y
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

}


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 
sudo adduser xrdp ssl-cert 
}
#--------------------------------------------------------------------------#
# -----------------------END Function Section -----------------#
#--------------------------------------------------------------------------#
#--------------------------------------------------------------------------#
#------------ MAIN SCRIPT SECTION -------------------# 
#--------------------------------------------------------------------------#
#---------------------------------------------------#
#-- Step 0 - 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 18.10"* ]];
then
/bin/echo -e "\e[1;32m |-| Ubuntu Version : $version\e[0m"
echo
elif [[ "$version" = *"Ubuntu 19.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 Ubuntu 18.04 Edition and later !\e[0m"
/bin/echo -e "\e[1;31m ! The script has been tested only on Ubuntu 18.04 and later !\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

/bin/echo -e "\e[1;33m |-| Detecting Parameters \e[0m"

#Detect if argument passed
if [ "$fixSound" = "yes" ]; 
then 
/bin/echo -e "\e[1;32m |-| Sound Redirection Option...: [YES]\e[0m"
else
/bin/echo -e "\e[1;32m |-| Sound Redirection Option...: [NO]\e[0m"
fi

if [ "$unofficialRepo" = "yes" ]; 
then 
/bin/echo -e "\e[1;32m |-| Unofficial Repo...........: [YES]\e[0m"
else
/bin/echo -e "\e[1;32m |-| Unofficial Repo...........: [NO]\e[0m"
fi
echo

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

echo
/bin/echo -e "\e[1;36m !-------------------------------------------------------------!\e[0m"
/bin/echo -e "\e[1;36m ! Installation Process starting.... !\e[0m"
/bin/echo -e "\e[1;36m !-------------------------------------------------------------!\e[0m"
echo
/bin/echo -e "\e[1;33m |-| Proceed with installation..... \e[0m"
echo

if [[ "$version" = *"Ubuntu 18.04."* ]];
then
/bin/echo -e "\e[1;32m |-| Ubuntu Version : $version\e[0m"
echo
/bin/echo -e "\e[1;36m !-------------------------------------------------------------!\e[0m"
/bin/echo -e "\e[1;36m ! Applying Installation Patch for Ubuntu 18.04.2 Only !\e[0m"
/bin/echo -e "\e[1;36m !-------------------------------------------------------------!\e[0m"
echo
if [ "$unofficialRepo" = "yes" ];
then
/bin/echo -e "\e[1;32m => Downloading Unofficial xRDP packages (Thiago Martins) !\e[0m"
echo
sudo add-apt-repository ppa:martinx/xrdp-hwe-18.04 -y
sudo apt-get update
install_xrdp
install_tweak
allow_console
create_polkit
fix_theme
fix_ssl
else
/bin/echo -e "\e[1;32m => Downgrading to previous xserver-xorg-* packages !\e[0m"
echo
install_xservercore
install_xrdp
install_tweak
allow_console
create_polkit
fix_theme
fi
else
install_xrdp
install_tweak
allow_console
create_polkit
fix_theme
fix_ssl
fi

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

#---------------------------------------------------#
# Step 9 - Credits .... 
#---------------------------------------------------#
echo
/bin/echo -e "\e[1;36m !------------------------------------------------------------------------------!\e[0m"
/bin/echo -e "\e[1;36m ! Installation Completed !\e[0m" 
/bin/echo -e "\e[1;36m ! Please test your xRDP configuration.A Reboot Might be required... !\e[0m"
/bin/echo -e "\e[1;36m ! Written by Griffon - Sept 2019 - Ver 0.6.1 - Std-Xrdp-Install-0.6.1sh !\e[0m"
/bin/echo -e "\e[1;36m ! !\e[0m"
/bin/echo -e "\e[1;36m ! Thanks to Thiago Martins who provided Updated xRDP packages for 18.04.2 :-) !\e[0m"
/bin/echo -e "\e[1;36m !------------------------------------------------------------------------------!\e[0m"
echo

How to Use the Script

Again, script usage is basically the same as the previous versions.  We will not go into details here but simply explain how to use it and how to execute it. 

Step 1 – Set Execute Right on the script

Download the Std-Xrdp-install-0.6.1.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/Std-Xrdp-Install-0.6.1.sh

Note : Adjust the path where the Std-Xrdp-Install-0.6.1.sh script to reflect your environment

Step 2 – How to execute the script ? 

With this version of the script, you can decide to pass no parameters or pass 2 parameters (which are -s  -u). The following section explains what are these options   

Standard way

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 

 ./Std-Xrdp-Install-0.6.1.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….

This installation mode will downgrade to older Ubuntu packages that can be used with xRDP and xorgxrdp packages if you are running Ubuntu 18.0.4.2 or 18.0.4.3.  This installation mode uses the quick and dirty fix…. 

Advanced way – Sound redirection 

If you want to use sound redirection within your remote session, you will need to run the script with the -s parameter.  When the -s parameter is passed, the sound redirection function will be executed and all the necessary actions would be performed by the script that will allow sound redirection.  To enable this additional feature within your remote desktop session, you will need to user the following syntax

To implement the sound redirection fix  within the xrdp session, use this syntax

./Std-Xrdp-Install-0.6.1.sh -s yes

When script execution is completed, the machine will not reboot so you can review the installation and detect possible elements that’s preventing the script execution.  At completion, it’s recommended to reboot the machine so the changes made to the system can be applied accordingly. 

Custom Option – using unofficial xRDP packages (use it if running Ubuntu 18.04.2 or 18.0.4.3)

If you are running Ubuntu 18.04.2 or later, you know that a small issue has been detected when installing the standard xrdp packages.  The issue will prevent the installation of the xorgxrdp package which will result in not being able to perform remote connection.  The script will detect this operating system and will take corrective actions in order to ensure that xrdp functionality will work after the installation process. 

However, the remediation process implies that some packages will be downgraded to a working version.  Some people might not like this approach.  So, we have included in the version 0.6 of the script the possibility to use unofficial xRDP packages that will be compatible with Ubuntu 18.04.2 while keeping the most recent version of needed packages to have xrdp installed properly. 

 If you want to use the unofficial xRDP packages, you will need to issue the following command 

./Std-Xrdp-Install-0.6.1.sh -u yes

This command will add some additional ppa repositories and will use these packages to perform the xRDP installation.  It’s important to note that this option will only work when running the script on Ubuntu 18.04.2 or later.  The script will check if you are running this version specifically and if you have used the -u option, unofficial packages will be used.

Obviously, you can combine the -s and -u parameters if you are running Ubuntu 18.04.2 operating system and you want to use sound redirection as well… 

./Std-Xrdp-Install-0.6.1.sh -u yes -s yes

Step 3 – Test your configuration 

After the script has run and after the reboot, it’s time to test and see if you can indeed perform a smooth remote connection to your Ubuntu machine.  Remember that a user can either be logged on locally or logged on remotely on the machine when working with xRDP solution.  If the user, performing the remote connection, is logged into the system locally the remote connection will start but will be terminated immediately.  This is the way it works nowadays. 

So, ensure that the user performing the test is not locally logged on, start your favourite remote desktop client and perform your connection.  You will be presented with the green login screen. Enter your credentials.  If everything is ok, you should then see your Ubuntu desktop displayed in the remote session.  You should be good to go and start performing some of your work.  If you disconnect from your session, you should be able to reconnect to the same session and proceed with the work you were doing.   

Download the Script 

Please download the script :  Std-Xrdp-Install-0.6.1.zip

Final Notes

This is it for this “fast published” post !   

The Std installation script now includes proper support for Ubuntu 18.04.3 release and we can enjoy again a simple and smooth installation.  This would be probably the latest update of this script version.  As you are probably aware, we are working in merging custom and standard script into a single one (see here) which should allow us to follow in a more timely manner release cycles.  The script has not been fully tested and validated yet. So, if you have some time, give it a try and provide feedback.  If you find a bug or an issue with the script, let us know as well so we can try to fix it 

Stay tuned

That’s is for today 

Till next time 

 

 

 

 

 

10 thoughts on “xRDP – Install xRDP the easy way on Ubuntu 18.04.x and 19.04 (Scripted Installation – Version 0.6.1)

  1. @Ian,

    Thank you for letting us know… It has been fixed…. The link points to the correct file now….:-)
    Sorry for the inconvenience….

    Till next time
    See ya

  2. I have installed Std-Xrdp-Install-0.6.1.zip. And I can see the bug. When I launch an app to install new apps (GNOME Software) I can see: ¨ Unable to download updates: you do not have permission to install software. ¨ (RDP client: Remina, xRDP server: 19.04)

  3. The problem is wider. I enter the password, but I still can see “Authentication required. System policy prevents wi-fi scans”. I click “cancel” but I cam the same. So I cannot enter the system.

  4. @Dimitri;

    This is a known limitation of xRDP. Ubuntu is using Polkit technology. Polkit define what a local user is entitled to do on the system. Polkit also applies to remote connection where polkit is probably more restrictive..This is why you have the prompt for the password….and if you enter it, it’s probably showing you again a popup….

    We will write a post about that topic as it seems enough people are not aware of the polkit technology and limitations that can come from it….

    till next time
    See ya

  5. Hey buddy!

    My PPA isn’t required any more! 😀

    So, you can remove the code here:

    sudo add-apt-repository ppa:martinx/xrdp-hwe-18.04 -y

    …and adapt the script to use the new package:

    Now, Ubuntu fixed the problem and a new package is available on official repositories, called “xorgxrdp-hwe-18.04”, how cool is that!? lol

    Cheers!
    Thiago

  6. @Thiago;

    Thank you for the update about new xorgxrdp package…. I didn’t know that a new package was available…. will update posts/scripts accordingly

    Till next time
    See ya

  7. A long series of attempts to get the XRDP running on an Ubuntu VM, I finally found the solution. I use Parallels on my Mac. No matter which Ubuntu version, no matter which XRDP version or installation type I chose, the screen after logging in via XRDP was black.

    Now I have updated to the Parallels version 15, as there should be possible to operate the Ubuntu 19.04 without driver tools.

    I tested it with and without tools.
    Result: XRDP works great as long as you do not install the tools.

    I hope this helps others too.

  8. @Chris,

    Thank you for sharing the info and providing feedback on your testing and solution
    indeed, this can be helpful to other
    Thanks for your effort
    Till next time
    See ya

Leave a Reply