XRDP – Custom Install on Ubuntu 16.04.2 to Access Unity Desktop

Hello World, 

Today’s post is about xRDP, Unity and Ubunt 16.04.  

Why Ubuntu 16.04 ? For multiple reasons…

Because it a long term support (LTS) release which means that Canonical will provide support till 2020 or 2021.  Even do Canonical is dropping Unity Desktop interface in favor of Gnome Desktop in the next releases, a lot of people might still be working with Ubuntu 16.04 and Unity.   

Because one of our previous posts describing how to install xrdp through a custom script (install-xrdp.sh version 1.7) needs to be updated in order to reflect the recent changes affecting the xrdp package available on the web (xrdp version 0.9.x).  Some of our readers have been using this custom script and noticed that it was not working anymore…so we needed to update this one and make it work again…. 

This is exactly what will do…right now…. 

The Custom Installation Script (version 1.8)

Overview

By default, Ubuntu 16.04 ship with version 0.6.xx of the xrdp package.  It possible to install the Ubuntu provided xrdp package and perform a remote desktop connection into Unity Desktop (see this post). The instruction on this post should still be valid.  However, performing the standard installation of xrdp 0.6.xx implies that features like Drives Redirection or Clipboard capability are not available through this instruction process.  

As you can imagine, we also published a post explaining how to perform the custom installation of xrdp on Ubuntu 16.04 and have Drive redirection and Clipboard features enabled.  The ease the installation and configuration, a custom installation script has been created and published.  At that time the script was at version 1.7.  Because of the major changes affecting the xrdp package 0.9.xx, the script version 1.7. should not be used anymore and you should instead use the latest version of the script (i.e. version 1.8) which will be provided through this post…. 

Assumptions

Before running this script, be aware of the following assumptions

  • We have tested the script on Ubuntu 16.04 Update 2
  • 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
  • This script should be run only on Ubuntu 16.04.2 (so far) as we have not tested it on higher version. 

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.8

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

Version 1.8 does not introduces major changes.  it simply take into account the fact that in order to compile xrdp from source, you need to follow a specific order.  First compile xrdp and then compile xorgxrdp. The incremental version is due to the fact that we have added into the script the possibility to populate automatically the .xsession file and have Unity Desktop with Indicator panel loaded when performing the remote Desktop connection. We have also created the polkit file in order to avoid annoying popups when connected to the XRDP session. Finally,  Drives redirection and Clipboard feature should be available as well after the script has completed….. 

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

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

##################################################################
#Step 1 - Install prereqs for compilation
##################################################################

echo "Installing prereqs for compiling xrdp..."
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 git 

##################################################################
#Step 2 - Obtain xrdp packages 
################################################################## 

#-Go to your Download folder
echo "Moving to the ~/Download folders..."
echo "-----------------------------------"
cd ~/Downloads

#Download the xrdp latest files
echo "Ready to start the download of xrdp package"
echo "-------------------------------------------"
git clone https://github.com/neutrinolabs/xrdp.git

##################################################################
#Step 3 - compiling xrdp packages
################################################################## 

echo "Installing and compiling xrdp..."
echo "--------------------------------"
cd ~/Downloads/xrdp
./bootstrap
# We can enable more options -- Check Documentation
./configure --enable-fuse --enable-jpeg
make
sudo make install

##################################################################
#Step 4 - compiling xorgxrdp packages
################################################################## 

cd ~/Downloads
git clone https://github.com/neutrinolabs/xorgxrdp.git

cd ~/Downloads/xorgxrdp 
./bootstrap 
./configure 
make
sudo make install

##################################################################
#Step 5 - Updates service Unit Files
################################################################## 

## Needed in order to have systemd working properly with xrdp
echo "-----------------------"
echo "Modify xrdp.service "
echo "-----------------------"
#Comment the EnvironmentFile - Ubuntu does not have sysconfig folder
sudo sed -i.bak 's/EnvironmentFile/#EnvironmentFile/g' /lib/systemd/system/xrdp.service
#Replace /sbin/xrdp with /sbin/local/xrdp as this is the correct location
sudo sed -i.bak 's/sbin\/xrdp/local\/sbin\/xrdp/g' /lib/systemd/system/xrdp.service

echo "-----------------------"
echo "Modify xrdp-sesman.service "
echo "-----------------------"

#Comment the EnvironmentFile - Ubuntu does not have sysconfig folder
sudo sed -i.bak 's/EnvironmentFile/#EnvironmentFile/g' /lib/systemd/system/xrdp-sesman.service
#Replace /sbin/xrdp with /sbin/local/xrdp as this is the correct location
sudo sed -i.bak 's/sbin\/xrdp/local\/sbin\/xrdp/g' /lib/systemd/system/xrdp-sesman.service

#Issue systemctl command to reflect change and enable the service
sudo systemctl daemon-reload
sudo systemctl enable xrdp.service

##################################################################
#Step 6 - Updates .xsession file 
##################################################################
## copy the following in the .xsession file
cat >~/.xsession << EOF
/usr/lib/gnome-session/gnome-session-binary --session=ubuntu &
/usr/lib/x86_64-linux-gnu/unity/unity-panel-service &
/usr/lib/unity-settings-daemon/unity-settings-daemon &

for indicator in /usr/lib/x86_64-linux-gnu/indicator-*; 
do
basename='basename \${indicator}' 
dirname='dirname \${indicator}' 
service=\${dirname}/\${basename}/\${basename}-service 
\${service} &
done
unity
EOF

## Configure Polkit to avoid popu in Xrdp Session

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(“{group}”)) {
return polkit.Result.YES;
}
});
EOF

echo "Restart the Computer"
echo "----------------------------"
sudo shutdown -r now

 

How to use the script

Set Execute Right on the script

Download the install-xrdp-1.8.sh script to your system.  To have it running, the script has to be marked as executable.  To mark a script/file as executable, the following actions needs to be performed 

Right-click on the file, go to properties, then select permissions and tick the box allow executable….

xrdp_custom

Click on Picture for better resolution 

or from the command line, issue the following command

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

 

Note : Adjust the path where the install-xrdp-1.8.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 

sudo ./install-xrdp-1.8.sh  

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

Wait for completion of the script.  The machine will reboot automatically when done.

Test your xRDP Connection

When the Ubuntu machine is up and running, it’s time to perform your remote desktop connection.  So, Open your favorite remote desktop client, provide ip address or hostname of your Linux machine and connect.  If the xrdp service is listening, the xrdp login screen will be presented to you

U1704_xrdp_3

Click on picture for better resolution

 

Because we are using the package 0.9.xx, there is no need to configure keyboard layout in the xrdp login screen or during the xrdp session.  The keyboard layout should be detected automatically.  However, if you still see that the keyboard layout within the xrdp session does not match your settings, simply use the language in indicator bar to set the proper language settings..

U1704_xrdp_8

Click on picture for better resolution

Improvements detected 

In this post, installing xrdp and have it working with Ubuntu 17.04 and Unity is feasible but there are still some caveats.  The major annoyance with xrdp and Unity in Ubuntu 16.10 and 17.04 is the fact that a user can be connected only through one session.  If a user is connected to the console, the same user cannot perform a remote desktop connection.  The other way is true as well.  If the user is remotely connected, he cannot connect to the console. This would fail (infinite loop to login page).  In Ubuntu 16.10 and 17.04, the .xsession file does not seems to work anymore and we recently found out that to have the Unity destkop started automatically, we could simply execute a specific startup application script.  (see  this post). 

The install-xrdp-1.8.sh seems to remove all these constraints. After executing the script, we have been able to connect to the remote session while still logged into the console.  The Unity Desktop is launching automatically through the .xsession file and the indicator Panel bar is loaded as well.  All in all the user experience is smoother when accessing the Unity Interface through xRDP. 

Issues detected 

The noticeable issues found so far are still the performance and the logout functionality.  Over the LAN, the performance are acceptable but still not as good as you would expect when logged into the console.  The other problem is the logout option.  If a user decide to logout from the xrdp session, the user can click on the logout button (on the indicator panel) and after some time the session will be closed.  However, next time the user would try to connect, xrdp would fail. 

The best workaround we can offer is to encapsulate the following command into a script and create a shortcut on the Desktop of the user and instruct them to use this shortcut to logout from a remote session. This approach would ensure that when a user tries to reconnect, xrdp will accept the connection request

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

 

Download the Script 

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

Final Notes

In this post, we have spend again a little bit of time on Ubuntu 16.04 and xRDP while Ubuntu 17.04 is out and that 17.10 will ship with Gnome 3 as default desktop.   As Ubuntu 16.04 is an LTS release, we are expecting to have a lot of people sticking to it and still use Unity Desktop.   

Using the custom installation procedure against Ubuntu 16.04.2, latest version of xRDP software can be installed and surprisingly, it even offer a better or smoother experience compared to the standard installation on Ubuntu 17.04…  Unity Desktop is launched automatically, indicator panel is there and the same user can be connected locally and remotely to the same machine….   This is a real workable solution…. 

We still need to investigate xRDP against Ubuntu Gnome as this will become the default Desktop environment….but this will be for a later stage…..

I hope you will enjoy the small improvements….

Till next time

See ya

 

 

 

8 thoughts on “XRDP – Custom Install on Ubuntu 16.04.2 to Access Unity Desktop

  1. Hello and thanks for these posts.

    The downloadable script is not, ehm, a script. It is an exception stack trace 🙂

    Regards!

  2. Help!!! ))

    checking for XRDP… no
    configure: error: Package requirements (xrdp >= 0.9.0) were not met:
    No package ‘xrdp’ found

    while ./configure

  3. Hello DavidC,

    Thank you for letting us know that the download file was not the correct one… We have updated the post and the new download file should be the good one…

    Thank you for the feedback and detectig issues on this blog. if there is still an issue; do not hesitate and let us know…
    Till next time
    See ya

  4. @Grif,

    This can happen if the xrdp package is not yet installed… so you first need to install the xrdp package (download and compile) and then install (compile the xorgxrdp). we have noticed that sometimes the script fails to make the connection to the github…we have changed slightly the script so now it should be ok
    Sorry for the inconvenience
    Please try again (downloading the script at the end of the post) and provide feedback… Thank you for your help in improving this blog…

    Till next time
    See ya

  5. Hi,
    Thanks for this post.
    I install xrdp according to this post. It works. But there are two problems with it:
    First:
    I cannot open my home folder. When I try to open my home folder, an error window appears and says:

    > Failed to open directory ‘user’.
    > Error when getting information for file ‘/home/user/thinclient_drives’: Transport endpoint is not connected.

    I opened /home/user in terminal. There is a ‘thinclient_drives’ folder that its permission is as “d?????????”.
    The folder is not a normal folder and it seems it was created by xrdp.

    Second:
    After some time the connection is terminated with the following error:
    An internal error has occurred.

    Ubuntu 16.04.2
    xfce

    Please help me.
    Best.

  6. Hi
    According to a comment on the Internet, I change ‘thinclient_drives’ to ‘.thinclient_drives’ in the config file, and the problem was resolved.
    Thanks.

  7. Hi, after following this guide on 16.04 LTS, I noticed that compiz was killing my CPU. I saw that in Additional Drivers it is using the x.org nouveau driver and pushing all graphics to CPU. I installed the appropriate nvidia driver for my card (proprietary,tested binary nvidia-340), rebooted, and now when I RDP from my windows box, i get the login screen.. but when i press log in, the form goes away and it stays that light blue screen. Is it possible to have the xRDP session render using the GPU? Should I try an alternative desktop (you mentioned Mate-Desktop in another post) Thanks!

  8. @Rick,

    You can try indeed the Mate-desktop which should be less xorg demanding….we never checked if xrdp could take advantage of GPU…might be a coming post 🙂

    till next time
    See ya

Leave a Reply