XRDP- HowTo Custom install on Ubuntu 16.04.x with Unity Interface (install-xrdp-1.9.2.sh)

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

 

Hello World, 

Ubuntu 18.04 is on its way and we are already looking and preparing some posts about xRDP and this exciting to come LTS Ubuntu Release.   However, Ubuntu 16.04 is also an LTS release and some people might be still using it for the coming years as well.  The problem with Ubuntu 16.04 is that the xrdp package that ship by default is an outdated package (version 0.6.1) compared to the version available on the xRDP web site (version 0.9.5).     This outdated package provides limited Remote desktop capabilities as it’s not providing Drive Redirection nor Clipboard support.  

To overcome this situation, one approach consist of perform an custom installation from sources binaries.    To provide easy installation and automation on Ubuntu systems, a little script has been developed that can be used to perform a custom installation of xRDP.  The script exists for some time now and has been updated with the different Ubuntu versions or features that would be made available with time.  

Because Ubuntu 16.04 is an LTS release, we have decided to update the install-xrdp.sh script and check that this is still working with the recently Unity Update made available by Canonical. Minor changes have been made. It’s more about cleanup of the code and removal of unnecessary code. 

So, let’s move on ! 

The Custom Installation Script – Version 1.9.2

Overview

The version 1.9.2 script has been updated and tested on the latest Ubuntu 16.04 version (16.04.4).  The updates are mainly cosmetic. 

  • We have updated the code used to detect the Ubuntu version (version 1.9.1 had an invalid code but has been fixed since then…:-) ).
  • We have updated the code to check if Unity Desktop is in used or not
  • We have updated the polkit section.  A specific group (i.e. users) has been used
  • This script configure the system to allow  multipe users by default (no need to create for each user a .xsession file)
  • Cleanup a little bit the code and add some additional checks as needed
  • We have changed the section where the fontutil.h file was created because of a small bug in Ubuntu 16.04.3. Apparently, the bug has been fixed (*)

(*) When Ubuntu 16.04.3 was released initially, a bug was identified which was preventing the installation of a custom xRDP package.  These bugs have been fixed and there is not need anymore to recreate the fontutil.h file on the system.   You can find more information about these changes in behavior and bugs in the following posts 

As this bug has been fixed, there is no need to create the file through the script but the script still check if needed or not to recreate the file 

Assumptions

Before running this script, be aware of the following assumptions

  • We have tested the script on Ubuntu 16.04 Update 3 and Update 4. 
  • The script should be working on Ubuntu 16.04 (whatever the Update version) 
  • No additional desktop interface has been installed. Unity Desktop will be the default interface in the remote sessions
  • We have performed the test on a Virtual Machine running on Hyper-V Server and Virtual box 
  • This script configure the .xsession file for  multipe users.

 

Click on Picture for Better Resolution

Prerequisites

We assume that you have internet connection on the Ubuntu machine.  The internet connection is needed to download the latest version xrdp package.  If you are not connected to internet, you can still manually download the xrdp package and modify the install-xrdp.sh script accordingly

The script version 1.9.2

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

################################################################
# Script_Name : install-xrdp-1.9.2.sh
# Description : Perform an automated custom installation of xrdp
# on ubuntu 16.04.4
# Date : March 2018
# written by : Griffon
# Web Site :http://www.c-nergy.be - http://www.c-nergy.be/blog
# Version : 1.9.2
# Disclaimer : Script provided AS IS. Use it at your own risk....
##################################################################

#----------------------------------------------------------------# 
# Step 0 - Try to Detect Ubuntu Version and Unity.... 
#----------------------------------------------------------------#
clear
#Checking Ubuntu Version
echo
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m" 
/bin/echo -e "\e[1;32m Dectecting Ubuntu Version and Desktop in use...\e[0m"
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"

version=$(lsb_release -d | awk -F":" '/Description/ {print $2}')

if [[ $version=*"Ubuntu 16.04"* ]]; then 
echo
/bin/echo -e "\e[1;33m Ubuntu Version :$version\e[0m"
else 
/bin/echo -e "\e[1;31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m" 
/bin/echo -e "\e[1;31mYour system is not running Ubuntu 16.04 Edition.\e[0m" 
/bin/echo -e "\e[1;31mThe script has been tested only on Ubuntu 16.04.x...\e[0m" 
/bin/echo -e "\e[1;31mThe script is exiting...\e[0m" 
/bin/echo -e "\e[1;31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m" 
echo
exit 
fi

#Checking if Unity Desktop in Use

if [ "$XDG_CURRENT_DESKTOP"="Unity" ] 
then 
/bin/echo -e "\e[1;33m Desktop interface Detected....: $XDG_CURRENT_DESKTOP\e[0m" 
echo 
else 
/bin/echo -e "\e[1;31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m" 
/bin/echo -e "\e[1;31mYour system is not running Unity Desktop Interface.\e[0m" 
/bin/echo -e "\e[1;31mThe script has been written to enable Unity Desktop in remote session...\e[0m" 
/bin/echo -e "\e[1;31mThe script is exiting...\e[0m"
/bin/echo -e "\e[1;31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
exit 
fi

#---------------------------------------------------#
# Step 1 - Download XRDP Binaries... 
#---------------------------------------------------#

/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m" 
/bin/echo -e "\e[1;32m Downloading xRDP binaries and tools...\e[0m"
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m" 
echo
/bin/echo -e "\e[1;33m Installing Git....Proceeding \e[0m"
echo 
sudo apt-get -y install git
echo
cd ~/Downloads

## -- Download the xrdp latest files
echo
/bin/echo -e "\e[1;33m Preparing download xrdp package...Proceeding\e[0m"
echo
git clone https://github.com/neutrinolabs/xrdp.git
echo
/bin/echo -e "\e[1;33m Preparing download xorgxrdp package...Proceeding\e[0m"
echo
git clone https://github.com/neutrinolabs/xorgxrdp.git


#---------------------------------------------------#
# Step 2 - Install Prereqs... 
#---------------------------------------------------#
echo
/bin/echo -e "\e[1;33m Installing Prereqs....Proceeding\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 xserver-xorg-dev fuse pkg-config

#---------------------------------------------------#
# Step 3 - Check if Fontutil.h file exists... 
#---------------------------------------------------#

#checking if file exists...
echo
/bin/echo -e "\e[1;33m Checking fontutil.h file....Proceeding\e[0m" 
echo

file="/usr/include/X11/fonts/fontutil.h"

if [ -f "$file" ]
then
echo 
/bin/echo -e "\e[1;37m Fontutil.h exist...Moving Next step \e[0m"
echo
else
echo
/bin/echo -e "\e[1;37m Fontutil.h will be created by script...Proceeding \e[0m"

echo
cat >/usr/include/X11/fonts/fontutil.h <<EOF
#ifndef _FONTUTIL_H_
#define _FONTUTIL_H_

#include <X11/fonts/FSproto.h>

extern int FontCouldBeTerminal(FontInfoPtr);
extern int CheckFSFormat(fsBitmapFormat, fsBitmapFormatMask, int *, int *,
 int *, int *, int *);
extern void FontComputeInfoAccelerators(FontInfoPtr);

extern void GetGlyphs ( FontPtr font, unsigned long count,
 unsigned char *chars, FontEncoding fontEncoding,
 unsigned long *glyphcount, CharInfoPtr *glyphs );
extern void QueryGlyphExtents ( FontPtr pFont, CharInfoPtr *charinfo,
 unsigned long count, ExtentInfoRec *info );
extern Bool QueryTextExtents ( FontPtr pFont, unsigned long count,
 unsigned char *chars, ExtentInfoRec *info );
extern Bool ParseGlyphCachingMode ( char *str );
extern void InitGlyphCaching ( void );
extern void SetGlyphCachingMode ( int newmode );
extern int add_range ( fsRange *newrange, int *nranges, fsRange **range,
 Bool charset_subset );

#endif /* _FONTUTIL_H_ */
EOF
 
fi

#---------------------------------------------------#
# Step 4 - compiling... 
#---------------------------------------------------#
# -- Compiling xrdp package first

echo
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m" 
/bin/echo -e "\e[1;32mXRDP Compilation about to start !... \e[0m"
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
echo

cd ~/Downloads/xrdp
sudo ./bootstrap
sudo ./configure --enable-fuse --enable-jpeg 
sudo make

#-- check if no error during compilation

if [ $? -eq 0 ]
then 
echo
/bin/echo -e "\e[1;37m-----------------------------------\e[0m"
/bin/echo -e "\e[1;37mMake Operation Successful ! \e[0m"
/bin/echo -e "\e[1;37m-----------------------------------\e[0m"
echo
else 
echo
/bin/echo -e "\e[1;31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
/bin/echo -e "\e[1;31mError while executing make.\e[0m"
/bin/echo -e "\e[1;31mThe script is exiting...\e[0m"
/bin/echo -e "\e[1;31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
echo
exit
fi
sudo make install

# -- Compiling xorgxrdp package first

echo
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m" 
/bin/echo -e "\e[1;32mxorgxrdp Compilation about to start !... \e[0m"
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
echo
cd ~/Downloads/xorgxrdp 
sudo ./bootstrap 
sudo ./configure 
sudo make

# check if no error during compilation 
if [ $? -eq 0 ]
then 
echo
/bin/echo -e "\e[1;37m-----------------------------------\e[0m"
/bin/echo -e "\e[1;37mMake Operation Successful ! \e[0m"
/bin/echo -e "\e[1;37m-----------------------------------\e[0m"
echo
else 
/bin/echo -e "\e[1;31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
/bin/echo -e "\e[1;31mError while executing make.\e[0m"
/bin/echo -e "\e[1;31mThe script is exiting...\e[0m"
/bin/echo -e "\e[1;31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
echo
exit
fi
sudo make install

#---------------------------------------------------#
# Step 5 - create policies exceptions .... 
#---------------------------------------------------#

echo
/bin/echo -e "\e[1;33m Creating Polkit file...Proceeding\e[0m" 
echo

cat >/etc/polkit-1/localauthority.conf.d/02-allow-colord.conf <<EOF

polkit.addRule(function(action, subject) {
if ((action.id == “org.freedesktop.color-manager.create-device” ||
action.id == “org.freedesktop.color-manager.create-profile” ||
action.id == “org.freedesktop.color-manager.delete-device” ||
action.id == “org.freedesktop.color-manager.delete-profile” ||
action.id == “org.freedesktop.color-manager.modify-device” ||
action.id == “org.freedesktop.color-manager.modify-profile”) &&
subject.isInGroup(“{users}”)) {
return polkit.Result.YES;
}
});
EOF

#---------------------------------------------------#
# Step 6 - configure Xwrapper file .... 
#---------------------------------------------------#

echo
/bin/echo -e "\e[1;33m Configuring Xwrapper(optional)...Proceeding\e[0m" 
echo

sudo sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config

#---------------------------------------------------#
# Step 7 - Populate the .xsession file multi-users # 
#---------------------------------------------------#

echo
/bin/echo -e "\e[1;33m Configuring startwm.sh for multi-users login...Proceeding\e[0m" 
echo

sudo sed -i.bak "/# 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

#---------------------------------------------------#
# Step 8 - create services .... 
#---------------------------------------------------# 
echo
/bin/echo -e "\e[1;33m Creating xRDP Services...Proceeding\e[0m" 
echo

sudo systemctl daemon-reload
sudo systemctl enable xrdp.service
sudo systemctl enable xrdp-sesman.service
sudo systemctl start xrdp

#---------------------------------------------------#
# Step 9 - install additional packages .... 
#---------------------------------------------------#

echo
/bin/echo -e "\e[1;33m Installing xserver-xorg-core pacakges...Proceeding\e[0m" 
echo
sudo apt-get -y install xserver-xorg-core

echo
/bin/echo -e "\e[1;33m checking Virtualization Platform...Proceeding\e[0m" 
echo

vmversion=$(sudo dmidecode -s system-product-name)
echo $vmversion
if [ "$vmversion" = "VirtualBox" ]
then 
 sudo apt-get -y install xserver-xorg-input-all
else
 echo "no additional package needed" 
fi
 
/bin/echo -e "\e[1;32m----------------------------------------------------------\e[0m"
/bin/echo -e "\e[1;32mInstallation Completed\e[0m"
/bin/echo -e "\e[1;32mPlease test your xRDP configuration....\e[0m"
/bin/echo -e "\e[1;32mCheck c-nergy.be website for latest version of the script\e[0m"
/bin/echo -e "\e[1;32mwritten by Griffon - March 2018 - Version 1.9.2\e[0m"
/bin/echo -e "\e[1;32m----------------------------------------------------------\e[0m"
echo

How to Use the Script

Set Execute Right on the script

As before, you first need to download the install-xrdp-1.9.2.sh script to your system. Then you  have to mark it as executable so the system can run this script. To do this, simply right-click on the file, go to properties, then select permissions tab and tick the box allow executable….

Click on Picture for better resolution 

or from the command line, issue the following command

chmod +x  ~/Downloads/install-xrdp-1.9.2.sh  

Note : Adjust the path where the install-xrdp-1.9.2.sh script to reflect your environment

Execute the script

To execute the script, ensure that internet connection is available (so you can download the necessary packages needed for the installation) and simply open a Terminal console.  In the Terminal console, Browse to the location where the script has been stored and then issue the following command 

./install-xrdp-1.9.2.sh  

You will be prompted for a password. Provide the password and proceed with the installation.

Click on Picture for better resolution 

Wait for completion of the script.  The machine will not reboot automatically when done so you can review the actions performed by the script….

Click on Picture for better resolution 

Test your xRDP Infrastructure

It’s time to check if XRDP is working as expected !  Open your remote desktop client, insert the name or ip address of the remote Ubuntu machine and try to connect.  If the xRDP service is started, you will see the usual xRDP Login screen with the green background.

Click on picture for better resolution

Type in your user account and password and after some time, you should have access to your Unity Desktop interface through the Remote Desktop client. 

Click on picture for better resolution

In Ubuntu 16.04.x, you can have the same user logged into the console and to the remote session and this scenario would work.  In later version of Ubuntu, it seems that the behavior has changed…  The user will be able to reconnect to an existing session as well and the user will be able to use the clipboard and drives redirection features.. 

Issues detected 

No new real issues detected in this version so far.   

Logout options

In this version, you can click on the logout option and this should be normally work out of the box. We have tried two three times and it seems to works (even do it’s a little bit slow).  If you have issues with logout actions, as in our previous posts, you can try to use the following command line (or make a custom shortcut that users can they use to logout in one step)

ps -ef h | grep xorgxrdp | grep `whoami` | tr -s " " | cut -d " " -f2 | xargs kill -9

Applications

We have checked that standard applications could be used through the remote desktop session.  Firefox starts up and we can browse internet, we have started up software center and we can install software. so far, all in all, we are able to perform some works through the remote desktop solution 

Performance 

We are not sure if it’s because we have really small virtual machines (only 2GB of RAM) but performance are not that great.  There can be long latency between the moment you have clicked a button and the action that should start after clicking.  We think that performance should be acceptable and people should be able to work if the remote machine has the necessary resources to run Unity Desktop Interface. 

Virtualization Platform 

On VirtualBox, after installing the xserver-xorg-core packages, we have noticed that it was not possible to login back into the Ubuntu machine directly (not through remote desktop session). This seems to be caused by the fact that keyboard and mouse drivers are removed during the install process (do not know how do).  So, to overcome this limitation, the script check for the virtualization platform (virtualbox or others) and add an additional xserver-xorg package so it’s still possible to login locally on the ubuntu machine.   The problem does not exist on Hyper-v…  

The script is taking care of this so the user does not need to perform any additional actions to overcome this possible limitation….

 

Download the Script 

Please download the script :  install-xrdp-1.9.2.zip

 

Bonus : A Quick Demo…. 

 

51 thoughts on “XRDP- HowTo Custom install on Ubuntu 16.04.x with Unity Interface (install-xrdp-1.9.2.sh)

  1. @Readhere,

    Thank you for the visit and the feedback….However, please note that you are using an obsolete version of the script which might explain why you had to manually perform these additional steps. Please always check for the latest version of the script at https://www.c-nergy.be/products.html. The last version available is the consolidated script which is now called xrdp-installer and is set to version 1.2. You can have a look at this post to have more info about this script https://c-nergy.be/blog/?p=14888

    Till next time
    See ya

Leave a Reply