xRDP – Easy install xRDP on Ubuntu 16.04,18.04,20.04,20.10 (Script Version 1.2.2)

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

Hello World, 

Based on users feedback, comments and suggestions, we are releasing a new version of the famous xrdp-installer script.  This new release basically fix some minor bugs that are addressed in this version and provide some better code logic.  We had no time to perform really extensive testing but we hope that these small changes will not break the script.  

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

So, let’s go ! 

Overview

The xrdp-installer-1.2.2.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 20.10 (recently released in October 2020). 

Script version & Supported Ubuntu Version

The script version will be set to 1.2.2. The xrdp-installer-1.2.2.sh script will support the following Ubuntu operating system version 

  • Ubuntu 16.04.x 
  • Ubuntu 18.04.x
  • Ubuntu 20.04.x
  • Ubuntu 20.10

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 16.04.x, Ubuntu 18.04.x, Ubuntu 20.04, Ubuntu 20.10)
  • The Official Ubuntu distribution needs to be used (we do not support other Ubuntu flavors so far  !! – this might change in the future ) 
  • No additional Desktop interface is used ( xRDP session will be showing Ubuntu Gnome Desktop with the Dock menu or Unity if running Ubuntu 16.04)
  • Sound functionality is present on the computers if you sound feature is available as well

What’s new in this release ?

As mentioned above, the script has not changed much and only a few minor changes have been introduced. It consist mainly of esthetic changes and minor bug fixes as well as including users feedback suggestions into the script.  So, the version 1.2.2 is addressing the following issues 

  • pointing to generic the ubuntu archive (archive.ubuntu.com) instead of using the localized one (be.archive.ubuntu.com) – Thanks to Thomas
  • obtain automatically xrdp and xorgxrdp package from github and use this information to build packages when custom installation mode is used (Thanks to Hiero)
  • force deletion of xrdp-installer-check.log file when remove option is selected to ensure that the xrdp folder is deleted accordingly (Thanks to Hiero)
  • automating script versioning 

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

How to Use the Script

The xrdp-installer-1.2.2 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 !!! 

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-installer-1.2.2.zip

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

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.2.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.2.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.2.sh

Note : Adjust the path where the xrdp-Installer-1.2.2.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.2.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.2.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.2.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….

Important Notes

If you are running the script on Ubuntu 16.04.x, the custom installation will always be performed even if you have not specified any parameters.  This is because Ubuntu 16.04.x ships with a really old xrdp package (version 0.6) and does not provides all needed features. The custom installation provide drive redirection, clipboard and access to Unity Desktop

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.2.sh -s      (this would enable the sound redirection) 
./xrdp-installer-1.2.2.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.2.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.2.sh -c     (this would perform a custom installation but will not enabled adv features like sound redirection or custom login screen)

Important Notes

If you are running the script on Ubuntu 16.04.x, the -c switch will be ignored and a custom installation process will be performed. This is because Ubuntu 16.04.x ships with a really old xrdp package (version 0.6) and does not provides all needed features. The custom installation provide drive redirection,clipboard and access to Unity Desktop

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.2.sh -c -s     (this would perform a custom install and enable sound redirection)
./xrdp-installer-1.2.2.sh -c -l     (this would perform a custom install and customize xrdp login screen)
./xrdp-installer-1.2.2.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.2.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.  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 favorite remote desktop client and perform your connection.  Based on your options, you will be presented either with the green xrdp login screen or with the custom login screen (purple background). 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 

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

For detailed information, see post below

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.

xrdp_redir_4

Click on picture for better resolution

xrdp_redir_5

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.

Limitations

One session per user limitation

Only one session is allowed per user.  This means that if a user is logged on locally on the Ubuntu machine, the user will not be able to perform a remote session (the xRDP connection will initiate but will end up immediately).  If a user is logged on remotely on the system, it will not be able to login locally (if the user tries to login locally, the login screen will loop and the login screen will be presented again to the user) 

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.2.2.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.2.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.2.sh
# Description : Perform xRDP installation on Ubuntu 16.04,18.04,20.4,20.10 and perform
# additional post configuration to improve end user experience
# Date : December 2020
# written by : Griffon
# WebSite :http://www.c-nergy.be - http://www.c-nergy.be/blog
# Version : 1.2.2 
# History : 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 python-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"* ]] ;
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

if [[ "$version" = *"Ubuntu 16.04"* ]];
then
echo
sudo sed -i "/# auth /a cat >~/.xsession << EOF\n#Unity Xrdp multi-users \n/usr/lib/gnome-session/gnome-session-binary --session=ubuntu &\n/usr/lib/x86_64-linux-gnu/unity/unity-panel-service &\n/usr/lib/unity-settings-daemon/unity-settings-daemon &\nfor indicator in /usr/lib/x86_64-linux-gnu/indicator-*;\ndo\nbasename='basename \\\\\${indicator}'\ndirname='dirname \\\\\${indicator}'\nservice=\\\\\${dirname}/\\\\\${basename}/\\\\\${basename}-service\n\\\\\${service} &\ndone\nunity\nEOF" /etc/xrdp/startwm.sh
echo
else 
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
fi
}

#---------------------------------------------------#
# 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 'deb http://archive.ubuntu.com/ubuntu/ '$codename' main restricted'
sudo apt-add-repository -s 'deb http://archive.ubuntu.com/ubuntu/ '$codename' restricted universe main multiverse'
sudo apt-add-repository -s 'deb http://archive.ubuntu.com/ubuntu/ '$codename'-updates restricted universe main multiverse'
sudo apt-add-repository -s 'deb http://archive.ubuntu.com/ubuntu/ '$codename'-backports main restricted universe multiverse'
sudo apt-add-repository -s '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
wget http://www.c-nergy.be/downloads/griffon_logo_xrdp.bmp

#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 "Directory /path/to/dir exists." 
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

#4F194C
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 
sudo apt-get autoremove xorgxrdp -y 
sudo apt-get purge xorgxrdp -y
}

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.2"
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 U16.04/18.04/19.10/20.04/20.10 !\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 16.04"* ]];
then
/bin/echo -e "\e[1;32m |-| Ubuntu Version : $version\e[0m"
echo
elif [[ "$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
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 ! U16.04.x/18.04.x/19.10/20.0X !\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 .... #
#---------------------------------------------------------#

#-------------------------------------------------------------------
#- If Ubuntu 16.04 detected, we always perform a custom installation
#-------------------------------------------------------------------

#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"
else
if [[ "$version" = *"Ubuntu 16.04"* ]];
then
echo
/bin/echo -e "\e[1;36m !-------------------------------------------------------------!\e[0m"
/bin/echo -e "\e[1;36m ! Custom Installation for Ubuntu 16.04.x !\e[0m"
/bin/echo -e "\e[1;36m !-------------------------------------------------------------!\e[0m"
echo
install_custom
install_common

fi

#---------------------------------------------------------------------------------------
#- If custom option detected, additional check for U16.04 so skipped
#----------------------------------------------------------------------------------------

if [[ "$version" != *"Ubuntu 16.04"* ]];
then
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
fi # end if version check not like U16.04
fi # End check if file exists
#---------------------------------------------------------------------------------------
#- 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 


 

 

68 thoughts on “xRDP – Easy install xRDP on Ubuntu 16.04,18.04,20.04,20.10 (Script Version 1.2.2)

  1. Hello,

    Thank you for accepting the suggestion, but…
    The version number of xorgxrdp in Ubuntu 20.04 is 1:0.2.12-1.
    Preceding “1:” is important.
    According to “man deb-version”, “0.2.15-1” is “0:0.2.15-1”.
    Therefor, “0.2.15-1” is older than “1:0.2.12-1”.

    sudo checkinstall –pkgname=xorgxrdp –pkgversion=$pkgver –pkgrelease=1 –default

    should be:

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

    Sorry for bother you.

    Thanks,
    Hiero

  2. @Hiero,

    Thanks for following up and providing good feedback… You are totally right. We just checked it… indeed, there is a need to add a preceding 1 in the packver variable…

    Will be fixed quite quickly and the post will be updated accordingly

    Really thank you for your feedback… really appreciated : -)

    Till next time
    See ya

  3. @Hiero;

    The post has been updated and the script as well…
    So, now the xorgxrdp package created with the checkinstall should show 1:xxxxx

    Thanks for the input
    Till next time
    See ya

  4. Not a bug, perhaps a self-inflicted newbie operator issue. After I connect to the remote machine (running Ubuntu 20.10 aarch64), I get a blank screen. Of course, the annoying screen has gone away thanks to your script but I cannot get even the basic logon screen (that I used to get with the manual installation of xrdp).

    Suggestions on correcting my mistake(s) are welcome!

  5. Hello!

    My profuse apologies! Please disregard my previous message about “blank screen.” I rebooted the remote machine and was able to logon successfully. Of course, still had to enter the authentication key several times but that is not an issue for me.

    Thanks again for helping us stay productive with your prompt updates. Looking forward to buying you your beverage of choice soon.

    Kind regards.

  6. @Matha,

    ok, no problem… However, we are wondering which kind of popup you are receiving ? can you provide us with a screenshot ? or can you describe the message error that would be displayed
    We asking this because the purpose of the script is to have a smooth user experience….

    waiting for your feedback
    till next time
    See ya

  7. In your
    #—————————————————#
    # Function 2 – create policies exceptions ….
    #—————————————————#
    section, I added this:

    sudo bash -c “cat >/etc/polkit-1/localauthority/50-local.d/46-user-admin.pkla” <<EOF
    [user admin]
    Identity=unix-user:*
    Action=org.gnome.controlcenter.user-accounts.administration
    ResultAny=auth_admin_keep
    ResultInactive=no
    ResultActive=no
    EOF

    To allow my remote student admins to create new student accounts.
    Thank you for this script/tool.

    With regards,
    Will Midyette

  8. I found that I couldn’t log in with ROOT, and the screen closed instantly after successful login. I’m sure I rebooted and no one else logged in with the root account

  9. @Will,
    Thank you for visiting our blog and sharing your findings…..
    We will use the feedback provided to probably improve even more user experience when using xRDP. thank you for sharing your polkit configuration file 🙂

    Till next time
    See ya

  10. @LF2,

    We have tested the root login and it’s working fine for us… By default, xRDP will not prevent root login

    so we would need more information…..

    Which version of Ubuntu are you running (U20.04, 20.10, 18.04)
    How did you enabled the root login (Please describe the procedure and commands you have used)
    Have you changed any settings in the /etc/xrdp/xrdp.ini and /etc/xrdp/sesman.ini files ?
    Can you possibly submit some logs as well to see if we can find a hint to a possible solution ? Check
    /var/log/auth.log
    /var/log/xrdp-sesman.log
    /var/log/xrdp.log

    Waiting for your feedback
    Till next time
    See ya

  11. Oh no, I was thinking of deleting the original log. It would be clearer to report the error once again. I didn’t realize that all three logs were empty after the problem.
    My system is ubuntu 18.04.4 and the system is brand new
    I didn’t use a specific command to enable root login, but just set the root password
    I did not modify any configuration file, just installed “xrdp” using “xrdp-installer-1.2.2”

    I observed that I logged in once with a non-root account in Win10 and then with root. Both windows are automatically closed, and when I log in with another user, UBUNTU system will prompt “A problem has been detected with the system program, would you like to report the problem immediately?”

    But all three logs are empty.

    Thank you for your reply!

  12. @LF2,

    So, we are assuming here that you have opened the log file as a normal user… This might explain why the file looked empty. To see content of the log files, you would have issue the following command
    sudo nano /var/log/xrdp.log and if you have made connections, you would see content

    Which type of install have your performed (using the script) ? standard or Custom
    If you have used standard installation, there might be an issue when trying to login with root on UBuntu 18.04.x indeed…. we have tested this. So if xrdp version is set to 0.9.5, it seems that indeed that root login has random behavior
    If you have performed a custom install, you would be running xrdp version 0.9.14 or higher and we were able to login with the root account
    Again, we assume that you have enabled root account accordingly i.e.
    step 1 set a password
    step 2 modified the /etc/gdm3/custom.conf
    step 3 modified the /etc/pam.d/gdm-password file

    Hope this help
    Till next time
    See ya

  13. Hi, Griffon, first of all thank you for your great work on script.

    But, i have an issue. When i reconnect the session a cannot change keyboard layout any more.
    Ubuntu 20.10
    Do you know how i can fix it?

  14. @Oleh,

    If you can login, you should be able to change the keyboard layout using command line…. setxkbmap utility
    You can first query the layout that’s running by issuing the following command

    setxkbmap -query

    Then, you can set the correct keyboard layout using the same utility. To set belgian keyboard layout, you would type something like this

    setxkbmap -layout be

    There is also a xrdp utilty that you can use to set the proper keyboard configuration in xrdp (but in latest version this should not be needed) which is called xrdp-genkeymap
    Have a look at this post – http://c-nergy.be/blog/?p=10196 – (section keyboard) to see how to use it –

    Hope this help
    Till next time
    See ya

  15. I found a problem with KDE Partionmanager running on Lubuntu 20.04.

    In Lubuntu 20.04 the KDE Partitionmanager is preinstalled. When I directly access the desktop (without XRDP) and start KDE Partitionmanager it opens an authentication window and after authentication it works as expected.

    When I access the desktop of the Lubuntu machine via RDP (XRDP installed with xrdp-installer-1.2.2.sh) KDE Partitionmanager does not open an authentication window and seems to start without root permissions. It cannot access the devices though.

    The problem seems to be related with kpmcore_externalcommand. See https://bugs.kde.org/show_bug.cgi?id=426170 for details.

    Any idea how to fix this?

  16. @Cluwedo,

    Thank you for visiting our blog and providing some feedback.
    As we are not using KDE interface, we have no idea on how to fix this…We would need to spent a little bit of time on this issue. If some other readers, users are working with KDE interface and xRDP, please provide some feedback

    Till next time
    See ya

  17. Hello Cluwedo, Griffon,

    This issue is not related to KDE.
    Basically, it is not allowed to execute gui application as root in the remote desktop session.

    Though it is not recommended and risky from the view point of security,
    I think following commands should work.

    $ xhost si:localuser:root
    $ sudo partitionmanager

    It is better to execute following command after partitionmanager has been closed.
    $ xhost -si:localuser:root

  18. 1) Would you consider building a ppa with the modified packages? Then the user could install xrdp with modified themes, active directory authentication if desired, permission fixes, and sound redirection just by installing the packages.

    2) Have you installed guacamole? In 18.04, this was a provided package, but it is no longer present in 20.04. I have this setup in 18.04 to allow rdp connections through the web server. I run apache with guacamole/tomcat under /guacamole so all that is needed is an https connection to the remote server.

  19. @Tim Riker,

    Thank for the suggestion but

    With the current situation and workload, we are not thinking of building up a ppa. Maybe in the future…

    Till next time
    see ya

  20. Hi!

    After running the script and installing xrdp, I got a logon screen in the remote desktop client, but when I entered the username and password, I only got a black screen. I rebooted the system, but it didn’t help. please advise me what to do.

    Best regards,

  21. After I ran the script and installed xrdp, I got a remote desktop client login screen, but when I entered the username and password, I only got a black screen. I rebooted the system, but it didn’t help. please advise me what to do

  22. @Mikahil;

    sorry for the late answer..quite busy lately…
    Which version of ubuntu are you runnin 18.04 or 20.04 ?
    do you have nvidia graphic cards ?
    How did you run the script i.e. which mode standard mode or custom installation ?
    can you check your logs as well /var/logs/xrdp-sesman.log and /var/log/xrdp.log
    please ensure that the same user is not logged locally on the machine and you are trying to connect using the same account via xRDP. the same user can connect either locally or remotely

    waiting for your feedback
    Till next time
    See ya

  23. Hi @Griffon!

    Ubuntu 20.10 on Oracle VM VirtualBox 6.1.16
    Host machine AMD Rizen 5 3600x graphic card is Radeon RX5700
    I tried to install the script both in standard mode and in custom mode

    /var/logs/xrdp-sesman.log
    [20210216-19:55:32] [DEBUG] libscp initialized
    [20210216-19:55:32] [DEBUG] Testing if xrdp-sesman can listen on 127.0.0.1 port 3350.
    [20210216-19:55:33] [DEBUG] Closed socket 5 (AF_INET6 ::1 port 3350)
    [20210216-19:55:33] [INFO ] starting xrdp-sesman with pid 2291
    [20210216-19:55:33] [INFO ] listening to port 3350 on 127.0.0.1
    [20210216-19:56:19] [INFO ] A connection received from ::1 port 51672
    [20210216-19:56:19] [INFO ] ++ created session (access granted): username michael, ip ::ffff:10.0.2.2:54314 – socket: 12
    [20210216-19:56:19] [INFO ] starting Xorg session…
    [20210216-19:56:19] [DEBUG] Closed socket 9 (AF_INET6 :: port 5910)
    [20210216-19:56:19] [DEBUG] Closed socket 9 (AF_INET6 :: port 6010)
    [20210216-19:56:19] [DEBUG] Closed socket 9 (AF_INET6 :: port 6210)
    [20210216-19:56:19] [DEBUG] Closed socket 8 (AF_INET6 ::1 port 3350)
    [20210216-19:56:19] [INFO ] calling auth_start_session from pid 4945
    [20210216-19:56:19] [DEBUG] Closed socket 7 (AF_INET6 ::1 port 3350)
    [20210216-19:56:19] [DEBUG] Closed socket 8 (AF_INET6 ::1 port 3350)
    [20210216-19:56:19] [INFO ] /usr/lib/xorg/Xorg :10 -auth .Xauthority -config xrdp/xorg.conf -noreset -nolisten tcp -logfile .xorgxrdp.%s.log
    [20210216-19:56:19] [CORE ] waiting for window manager (pid 4946) to exit
    [20210216-19:58:29] [INFO ] shutting down sesman 1
    [20210216-19:58:30] [WARN ] receiving SIGHUP 1
    [20210216-19:58:30] [CORE ] window manager (pid 4946) did exit, cleaning up session
    [20210216-19:58:30] [INFO ] calling auth_stop_session and auth_end from pid 4945
    [20210216-19:58:30] [DEBUG] cleanup_sockets:
    [20210216-19:58:30] [INFO ] ++ terminated session: username michael, display :10.0, session_pid 4945, ip ::ffff:10.0.2.2:54314 – socket: 12
    [20210216-19:58:30] [INFO ] shutting down sesman 1
    [20210216-19:58:30] [DEBUG] Closed socket 7 (AF_INET6 ::1 port 3350)

    /var/log/xrdp.log
    [20210216-19:55:33] [INFO ] address [0.0.0.0] port [3389] mode 1
    [20210216-19:55:33] [INFO ] listening to port 3389 on 0.0.0.0
    [20210216-19:55:33] [INFO ] xrdp_listen_pp done
    [20210216-19:55:33] [DEBUG] Closed socket 7 (AF_INET6 :: port 3389)
    [20210216-19:55:35] [INFO ] starting xrdp with pid 2301
    [20210216-19:55:35] [INFO ] address [0.0.0.0] port [3389] mode 1
    [20210216-19:55:35] [INFO ] listening to port 3389 on 0.0.0.0
    [20210216-19:55:35] [INFO ] xrdp_listen_pp done
    [20210216-19:56:10] [INFO ] Socket 12: AF_INET6 connection received from ::ffff:10.0.2.2 port 54312
    [20210216-19:56:10] [DEBUG] Closed socket 12 (AF_INET6 ::ffff:10.0.2.15 port 3389)
    [20210216-19:56:10] [DEBUG] Closed socket 11 (AF_INET6 :: port 3389)
    [20210216-19:56:11] [INFO ] Using default X.509 certificate: /etc/xrdp/cert.pem
    [20210216-19:56:11] [INFO ] Using default X.509 key file: /etc/xrdp/key.pem
    [20210216-19:56:11] [ERROR] Cannot read private key file /etc/xrdp/key.pem: Permission denied
    [20210216-19:56:11] [DEBUG] TLSv1.3 enabled
    [20210216-19:56:11] [DEBUG] TLSv1.2 enabled
    [20210216-19:56:11] [DEBUG] Security layer: requested 11, selected 0
    [20210216-19:56:11] [DEBUG] Closed socket 12 (AF_INET6 ::ffff:10.0.2.15 port 3389)
    [20210216-19:56:11] [INFO ] Socket 12: AF_INET6 connection received from ::ffff:10.0.2.2 port 54314
    [20210216-19:56:11] [DEBUG] Closed socket 12 (AF_INET6 ::ffff:10.0.2.15 port 3389)
    [20210216-19:56:11] [DEBUG] Closed socket 11 (AF_INET6 :: port 3389)
    [20210216-19:56:11] [INFO ] Using default X.509 certificate: /etc/xrdp/cert.pem
    [20210216-19:56:11] [INFO ] Using default X.509 key file: /etc/xrdp/key.pem
    [20210216-19:56:11] [ERROR] Cannot read private key file /etc/xrdp/key.pem: Permission denied
    [20210216-19:56:11] [DEBUG] TLSv1.3 enabled
    [20210216-19:56:11] [DEBUG] TLSv1.2 enabled
    [20210216-19:56:11] [DEBUG] Security layer: requested 0, selected 0
    [20210216-19:56:11] [INFO ] connected client computer name: DESKTOP-LFRPNST
    [20210216-19:56:11] [INFO ] adding channel item name rdpdr chan_id 1004 flags 0x80800000
    [20210216-19:56:11] [INFO ] adding channel item name rdpsnd chan_id 1005 flags 0xc0000000
    [20210216-19:56:11] [INFO ] adding channel item name cliprdr chan_id 1006 flags 0xc0a00000
    [20210216-19:56:11] [INFO ] adding channel item name drdynvc chan_id 1007 flags 0xc0800000
    [20210216-19:56:11] [INFO ] Non-TLS connection established from ::ffff:10.0.2.2 port 54314: encrypted with standard RDP security
    [20210216-19:56:11] [DEBUG] xrdp_00001343_wm_login_mode_event_00000001
    [20210216-19:56:11] [INFO ] Loading keymap file /etc/xrdp/km-00000409.ini
    [20210216-19:56:11] [WARN ] local keymap file for 0x00000409 found and doesn’t match built in keymap, using local keymap file
    [20210216-19:56:18] [DEBUG] xrdp_wm_log_msg: connecting to sesman ip 127.0.0.1 port 3350
    [20210216-19:56:19] [INFO ] xrdp_wm_log_msg: sesman connect ok
    [20210216-19:56:19] [DEBUG] xrdp_wm_log_msg: sending login info to session manager, please wait…
    [20210216-19:56:19] [DEBUG] return value from xrdp_mm_connect 0
    [20210216-19:56:19] [INFO ] xrdp_wm_log_msg: login successful for display 10
    [20210216-19:56:19] [DEBUG] xrdp_wm_log_msg: started connecting
    [20210216-19:56:19] [INFO ] lib_mod_log_peer: xrdp_pid=4931 connected to X11rdp_pid=4947 X11rdp_uid=1000 X11rdp_gid=1000 client_ip=::ffff:10.0.2.2 client_port=54314
    [20210216-19:56:19] [DEBUG] xrdp_wm_log_msg: connected ok
    [20210216-19:56:19] [DEBUG] xrdp_mm_connect_chansrv: chansrv connect successful
    [20210216-19:56:19] [DEBUG] Closed socket 16 (AF_INET6 ::1 port 51672)
    [20210216-19:58:29] [DEBUG] Closed socket 18 (AF_UNIX)
    [20210216-19:58:29] [DEBUG] Closed socket 11 (AF_INET6 :: port 3389)
    [20210216-19:58:30] [DEBUG] xrdp_mm_module_cleanup
    [20210216-19:58:30] [DEBUG] Closed socket 17 (AF_UNIX)

    Thanx for your advices

  24. @Mikhail,

    Usually, when you have a black screen after performing a xrdp connection, it’s because you are already logged in into your Ubuntu machine using the same account….
    so, go to your Ubuntu Virtual Machine and logoff (or reboot it completely) but do not login on the machine….. Then try to perform a remote session using xRDP, you should see the desktop interface loading….
    If you have use the script, you should see the standard ubuntu desktop interface

    Hope this help
    Till next time
    See ya

  25. @Griffon,

    It doesn’t work for me. I tried to connect to my VM right after it booted up, and the black screen appeared again.
    Do you have any other thoughts or tips?

    Regards,

  26. @Mikhail,

    can you try to start the xrdp service in debug mode and then try to connect to it using MS RDP ?
    To start in debug mode, you have to login locally and execute the following
    open terminal session
    stop xrdp service (sudo systemctl stop xrdp)
    Go to directory where xrdp bin are located ( type which xrdp to see where the xrdp directory is located on your system )
    Go to the directory and type sudo ./xrdp -ns
    Open a second Terminal Console
    Go to directory where xrdp bin are located ( type which xrdp to see where the xrdp directory is located on your system )
    start the xrdp-sesman process by issuing the following commqnd
    sudo ./xrdp-sesman -ns

    Leave the console open

    Try to connect to your Ubuntu machine using MS RDP

    Hope this help
    Till next time
    See ya

  27. @Mikhail,

    If this is working, this means that there is a problem with user sessions….
    You can try the following to have it working “normally”….please note that this is really a workaround….
    Open the file /etc/xrdp/startwm.sh (ie sudo nano /etc/xrdp/startwm.sh from command line)
    Go at the bottom of the file and just before the line test -x /etc/X11/(…)
    add the following command
    export $(dbus-launch)
    Save it
    Restart your machine and try again

    Hope this help
    Till next time
    See ya

  28. @Griffon,

    That is not the way. An error occurs in win RDP after written export $(dbus=launch) into startwm.sh: ‘login failed for display 0’
    Looks like something wrong )

    regards,

  29. @Mikhail,

    Maybe you have a typo in your file….If I look at the comment you’ve posted, you have typed export $(dbus=launch)
    You need to type export $(dbus-launch) (dbus-launch and no dbus=launch !!!)

    The file should look like

    (…)
    export $(dbus-launch)
    test -x /etc/X11/Xsession && exec /etc/X11/Xsession
    exec /bin/sh /etc/X11/Xsession

    Waiting for feedback
    Till next Time
    See ya

  30. @Mikhail;

    Ok; so try to replace the line you’ve added with this code still in /etc/xrdp/startwm.sh

    unset DBUS_SESSION_BUS_ADDRESS
    unset XDG_RUNTIME_DIR

    and see if this is better….

    As a test, can you also create a new user on the ubuntu machine and try to get this user connected through xRDP to see if behavior changes and if the user account you are using might be the problem (I do not think so but you never know)

    Till next time
    See ya

  31. @Griffon,

    I created a new user and it worked. It still doesn’t work with the old one. And by the way – there is a possibility that the error “login failed for display 0” occurred due to an incorrectly enabled locale in windows rdp, so I input wrong password. I’ll check it out tomorrow.

  32. @Griffon – thanks a lot for creating this script and writing detailed description – really appreciate it.

    What is your/script’s expectation around
    1. If someone manually tried to run install XRDP?
    – are we expected to uninstall and revert back any other tooling we tinkered with? Or would be script do the needful and install/upgrade to get the needed modules to the expected final state?

    2. If someone ran your script using older version of Ubuntu, can they re-running the script to get the new goodness you are adding to the script

    What is your recommendation?

  33. Hi @Griffon – I tried using your script on Ubuntu 20.10 running on a RasperrbyPi 4b – and I am seeing failures during compilation of pulse audio

    make all-recursive
    make[1]: Entering directory ‘/tmp/pulseaudio-module-xrdp’
    Making all in src
    make[2]: Entering directory ‘/tmp/pulseaudio-module-xrdp/src’
    CC module_xrdp_sink_la-module-xrdp-sink.lo
    module-xrdp-sink.c:26:10: fatal error: config.h: No such file or directory
    26 | #include
    | ^~~~~~~~~~
    compilation terminated.
    make[2]: *** [Makefile:481: module_xrdp_sink_la-module-xrdp-sink.lo] Error 1
    make[2]: Leaving directory ‘/tmp/pulseaudio-module-xrdp/src’
    make[1]: *** [Makefile:418: all-recursive] Error 1
    make[1]: Leaving directory ‘/tmp/pulseaudio-module-xrdp’
    make: *** [Makefile:350: all] Error 2
    ./xrdp-installer-1.2.2.sh: line 379: cd: /tmp/pulseaudio-13.99.2/pulseaudio-module-xrdp/src/.libs: No such file or directory
    install: cannot stat ‘*.so’: No such file or directory
    install: cannot stat ‘*.so’: No such file or directory

    See full output of the script at
    https://1drv.ms/u/s!Ajm4NP5AmJxIj91pFH3EFH4aETQ-8w?e=nJBHHc

    Any suggestions?

  34. @Avi,
    as shown by the error, it seems that the pulseaudio config.h file is missing….to overcome this issue, you have to find the config.h file and copy it in ‘/tmp/pulseaudio-module-xrdp/src… This can happen if the source code of pulseaudio is not downloaded properly also…

    you can also try to run sudo apt-get install libconfig-dev and try again the script with only the -s switch
    finally, could be an issue with the source file that need to be checked

    hope this help
    till next time

  35. @AVI,

    Best approach is to use the script in removal mode and then re-run the script in install mode

    hope this help
    till next time
    see ya

  36. @Griffon,

    yep, it works with ‘export $(dbus-launch)’ for new created user, but doesn’t for old one

  37. @Mikhail,

    So ok…This means that functionality seems to work as expected (you can remote connect to your Ubuntu machine)…for the old account, I would delete and recreate it.. Possibly something is broken with this user
    Thanks for providing feedback and sharing your finding with us…..

    Till next time
    See ya

  38. hello,

    great script and great xrdp

    my remote servers is Debian 9, some of them work just with installing xrdp, adjusting “anybody”, some not and I take your script, edit OS to override detection with Ubuntu 16

    all went smooth, except stoped at making /usr/local/lib/xrdp, with permission problem (may be Debian problem, may be not), I manually create this directory, start script again, all get done

    then I edit /etc/xrdp/startwm.sh and comment out strings, that create ~/.xsession, and set to my DE – just “startkde”

    and then do remote connection to my server, get right, long awaited picture

    thanks for script!

  39. @ieleja,

    Thanks for the feedback and for sharing your findings with our readers…. Always happy to see that our work can be useful to others

    Till next time
    See ya

  40. Thanks a ton! Functioning sound is something I had never gotten to work on my own with xrdp. Is it not insane that this much scripting is needed to make RDP service fully operational on a distro as major as Ubuntu? Why don’t the pre-built packages just work?

  41. @Ben,

    Thank for visiting our blog and providing feedback. We do not know why distributions are not shipping pre-build packages of xRDP… However, since we are talking about linux, other people can help and provide some solution, workaround to close the gap. This is what we are trying to do with our script

    Till next time
    See ya

  42. @Griffon

    Awesome script, though doesn’t run on Pop!_OS… but should, considering that it’s Ubuntu based. Can you please update a script that it doesn’t exit if it’s not Ubuntu, but rather checks if distro is Ubuntu based and I’d suggest issue a warning in that case (and isn’t Ubuntu itself) rather than exits – what do you think?

    Also, as a separate note, I believe you mention that it won’t let you be logged in locally w/ same account as you are remote connecting (black screen in that instance), which was the case for me / my install, at least for some time, but I finally got it to work where I’m (always / I stay) logged in locally AND I (plus at the same time also my GF even, I believe… have to double check that) can RDP w/ same acc at the same time. Though the issue is that the remote screen stays black for about 15 to 30 seconds (I didn’t time it exactly) and then the desktop finally shows up, but not that big of a deal. I have an Ubuntu server that I set up about a year ago and back then I got it to work also, with no delay on the remote end and “infinite” logins, but I don’t remember what I did to have gotten that to work… maybe I’ll find the time to retrace my steps / check key config files.

  43. @max2veg,

    Thanks for visiting our blog and providing feedback.

    To quickly answer your question, the next version of the script (ver1.3) to be released in more or less 10 days is covering already all your comments/requests 🙂
    We are waiting the final release of Ubuntu 21.04 to do the final test with the script….

    Quick announcement

    – script ver 1.3 will be working against Ubuntu and Pop!_OS.
    – script ver 1.3 will allow same user to connect locally and remotely concurrently (but this will still be a different session !!!!)
    (*) in a few days, we will release a new post explaining how to have same user account to connect at the same time locally and remotely…

    We are already looking into having the script running against more distributions but in a non-official way (cause not fully tested). Pop!_OS addition is the first step in that direction….More to come in the next verision 🙂

    Stay tune and come back in a few days, download script version 1.3. and if you have time test version 1.3 and provide feedback …

    Till next time
    See ya

  44. Thank you, @Griffon – here’s some feedback:

    On Ubuntu 21.04 after running your script, after entering the login info, a black / blank screen pops up (via MS Remote Desktop on a Mac – though probably doesn’t matter). I know others have reported that and you wrote about that too, but I haven’t come across a solution (that’ll work for me).

    The kinda funny part is that, with that RDP connection open remotely and black background, I decided to start “Terminal” on the Ubuntu 21.04 w/ xrdp server running – (meta key, “ter…” typed into top search) and… nothing happens; however, looking at my Mac w/ MS Remote Desktop running still and connected to my Ubuntu 21.04 PC, I see that a terminal window showed up 🤣
    And just to make sure, I repeat the process, still with the MS Remote Desktop app open and connected and that terminal window in it… and nothing happened, so I thought… I dragged the window, and look there, it’s a second terminal window within the same remote session that spawned!🤷
    Also just to clarify, I’ve been logged in the whole time on my Ubuntu 21.04 PC…

  45. @max2veg,

    Thanks for the feedback and for visiting our blog. To answer quickly to your questions and comments

    Disclaimer – Please note that script version 1.2.2 has not been tested against Ubuntu 21.04. (we will be release next version soon)

    The behavior you are describing is known and it seems to be enforced by design by the xRDP team !!! Normally, you cannot have the same user logged on locally and remotely at the same time. You will end up with either black screen, disconnected session after 5-10 sec, or in a limbo situation where you can start some apps in your remote session which will then appear in the console session…..

    We have described the situation in the following post : xRDP – xRDP shows only black screen after authentication windows – HowTo Fix !

    We have provided some workarounds in the following post : xRDP – Allow multiple sessions (local and remote) for the same user – HowTo . But, we have noticed that since Ubuntu 21.04 is running Wayland Display server, behavior can be affected. If you want to give it a try, you have to go for option 3….More information will follow in this blog about xRDP and Ubuntu 21.04 since multiple issues seems to have showed up

    Hope this helps
    Till next time
    See ya

  46. @Griffon

    Thank you for the quick response. I noticed that also some other apps will not start locally anymore (I haven’t tested if they only now show up inside the remote session, I have to assume they do, considering that is the case w/ the Terminal app).

    With consideration of the above and the help of your input, I have concluded the following:

    1. Ubuntu 21.x w/ Wayland does bring speed benefits.
    2. Wayland is causing issues w/ xRDP.
    3. xRDP w/ multiple users, even w/ same one and w/ locally logged in same user, I got working flawlessly on Ubuntu 20.10 (but IDK how anymore… any files you’d like to request to help investigate, as you know xRDP without doubt better than I do, I’d be happy to provide – maybe that can be of help for your ultimate-solution-xRDP script).
    4. Thus, the costs outweigh the benefits of running Ubuntu 21.x (at least for me as of right now w/ 21.04 @ mid-2021).

    My next steps:
    * I will create a new partition and install Ubuntu 20.10 again w/ xRDP and copying all the relevant files of it from my other functioning 20.10 w/ xRPD multi-session same-user install.
    * I will try and keep this install of Ubuntu 21.04 on a partition and maybe make it bootable inside a VM for further testing.
    * I will eagerly await xRPD install script v1.3 and test it w/ the existing 21.04 – and if it fails to produce expected / required results, also against a VM and then new native (non-VM) 21.04 install.

Leave a Reply