XRDP- Perform a Custom installation on Ubuntu 15.10 (with Systemd)

Hello World,

We are back on Ubuntu and XRDP topic today.  The post will be quite straightforward as we are simply checking that the procedure to perform a custom XRDP installation on Ubuntu 15.04 is still valid for Ubuntu 15.10.

Important Note

Again, in this post, we are working with the beta 1 version of Ubuntu 15.10. If major changes will be introduced in Ubuntu 15.10 Final version, we will update this post accordingly.

So, let’s go !

Custom xrdp installation…but why ?

I have received a lot of feedback about our popular xrdp posts.  One of the question that came quite often was : Why do you bother performing a custom installation ?

If you perform a standard install of xrdp (see http://c-nergy.be/blog/?p=7984on Ubuntu 14.10 and later, it’s working fine and you can reconnect to the same session….This is working out of the box. So why do you still provide and update this custom procedure ?

The first reason is that we want to test the latest version of xrdp package (which is 0.9.x). The default package found in ubuntu 15.10 repository is version 0.6.1-2 (or similar).

The second reason is for the challenge and the willing to try new things.  Since Ubuntu 15.04, the traditional upstart component has been replaced with the systemctl component. By playing around with the custom installation, we have been discovering how the .service files are working when you work with the systemctl new component. It’s fun to learn new things everyday…

Finally, we like to perform custom installation because we can also customize a little bit more the look’n feel of the xrdp login session.  The latest version of the xrdp package includes some customization options and because we are curious and we like to customize look’n feel of our customers to match their visual identity.  This is why we are using this custom installation approach…

The Custom Installation Script (version 1.4)

Hereafter, we provide a script that can be used to perform the custom installaion.  The script is the latest version that have been written by us and works for Ubuntu 15.04 and 15.10

If you want to understand what the script does, you can have a look at this location (Ubuntu 14.04 – Perform a custom XRDP Install (using X11VNC).

Pre-requisites

In this script, we are installing the MATE-Desktop which is our favourite desktop environment.  If you want to use another, you will have to update the script provided hereafter

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

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.

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

################################################################
 # Script_Name : xrdp-install.sh
 # Description : Perform an automated custom installation of xrdp
 # on ubuntu 15.04 when systemd is used
 # Date : May 2015
 # written by : Griffon
 # Web Site :http://www.c-nergy.be - http://www.c-nergy.be/blog
 # Version : 1.4
 #
 # Disclaimer : Script provided AS IS. Use it at your own risk....
 #
 ##################################################################
 
 #-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 "-------------------------------------------"
wget https://github.com/neutrinolabs/xrdp/archive/master.zip
#Unzip xrdp package
echo "Extracting content of xrdp package..."
 echo "-----------------------------------"
 unzip master.zip
#Install prereqs for compilation
echo "Installing prereqs for compiling xrdp..."
 echo "----------------------------------------"
 sudo apt-get -y install autoconf libtool libpam0g-dev libx11-dev libxfixes-dev libssl-dev libxrandr-dev
#Install the desktop of you choice - I'm Using Mate Desktop
echo "Installing alternate desktop to be used with xrdp..."
 echo "----------------------------------------------------"
 sudo apt-get -y update
 sudo apt-get -y install mate-core mate-desktop-environment mate-notification-daemon --force-yes
 echo "Desktop Install Done"
 #Configure the Xsession file
 echo mate-session> ~/.xsession
#Install the X11VNC
 echo "Installing X11VNC..."
 echo "----------------------------------------"
sudo apt-get -y install x11vnc
#Add/Remove Ubuntu xrdp packages (used to create startup service)
echo "Add/Remove xrdp packages..."
 echo "---------------------------"
sudo apt-get -y install xrdp
 sudo apt-get -y remove xrdp
#Compile and make xrdp
echo "Installing and compiling xrdp..."
 echo "--------------------------------"
cd xrdp-master
 # needed because libtool not found in Ubuntu 15.04
 # Need to use libtoolize
sudo sed -i.bak 's/which libtool/which libtoolize/g' bootstrap
sudo ./bootstrap
 sudo ./configure
 sudo make
 sudo make install
#Final Post Setup configuration
 echo "---------------------------"
 echo "Post Setup Configuration..."
 echo "---------------------------"
echo "Set Default xVnc-Sesman"
 echo "-----------------------"
sudo sed -i.bak '/\[xrdp1\]/i [xrdp0] \nname=Xvnc-Sesman-Griffon \nlib=libvnc.so \nusername=ask \npassword=ask \nip=127.0.0.1 \nport=-1 \ndelay_ms=2000' /etc/xrdp/xrdp.ini
echo "Symbolic links for xrdp"
 echo "-----------------------"
sudo mv /etc/xrdp/startwm.sh /etc/xrdp/startwm.sh.backup
 sudo ln -s /etc/X11/Xsession /etc/xrdp/startwm.sh
 sudo mkdir /usr/share/doc/xrdp
 sudo cp /etc/xrdp/rsakeys.ini /usr/share/doc/xrdp/rsakeys.ini
## 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 daemeon-reload
 sudo systemctl enable xrdp.service
echo "Restart the Computer"
 echo "----------------------------"
 sudo shutdown -r now

Set Execute rights on the script

Copy/paste the script into a text file in your home directory and save it as xrdp-install.sh.  You need to make it executable before you can run it.  To make the script executable, you will perform the following action.

 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 you can use the command line to perform the same action. Open your Terminal console and issue the following command

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

(if the file is located in your home directory in the Download Directory. Adapt the path accordingly…)

custom_xrdp_15.04_1.PNG

Click on Picture for better resolution 

Execute the script

You are now ready to execute the script.   we assume that you have internet connection available.  The script needs to download the xrdp package (the latest version from the xrdp community) from internet.  When you are ready, you can execute the script by issuing the following command in the command prompt.

custom_xrdp_15.04_2.PNG

Click on Picture for better resolution 

We assume that you have downloaded or created the file in the your home folder under the Download folders.  If this is not the case, browse to the location and execute the script from there.

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

Configuring your xRDP keyboard layout

Manual Configuration

As in the past, the xRDP login screen will use by default an en-us keyboard layout. You remote session will also be using the en-us keyboard layout.  This can be changed.  In my case, I’m using a Belgian French keyboard, so I had to tell xrdp to use the belgian french keyboard as well.  To do that, you need to perform the following actions :

Step 1 : You go to the /etc/xrdp directory

Step 2 : you issue the command setxkbmap -layout <%your layout%> to define which keyboard map/layout to use

XRDP_15.04_5.PNG

Click on Picutre for better Resolution 

Step 3 : create a copy of the km-0409.ini file into the same directory. It seems that this is the default file used by xrdp to define the keyboard layout. You will need to use sudo in order to be able to write into the directory

Step 4 : Check that you have a backup of your file by typing the dir or ls command

Step 5 : update the file by issuing the following command sudo xrdp-genkeymap km-0409.ini

XRDP_15.04_6.PNG

Click on Picutre for better Resolution 

Test your xRDP Connection

To test that your custom installation is working, simply open the rdp client on a windows machine, provide the requested information and see if you can connect. If the xrdp installation completed successfully, you should see the xRDP login screen (see screenshot)

custom_xrdp_15.04_3.PNG

Click on Picture for better resolution

To test that, you can reconnect to the same session, open some applications and then disconnect. You should see that the applications that you have opened are still there up and running.

Check also your keyboard layout in the xRDP login and check that the layout has been set correctly. Remember that by default, xRDP login screen will use EN-US keyboard layout if you do not have configured any other additonal keyboard layout (see section above).

Final Notes

As you can see, the installation process is exactly the same as the one for Ubuntu 15.04.  No changes are foreseen for the version 15.10. The script take into account the fact that systemd is in place and the script automatically update the service file used by xrdp to have xrdp starting properly.

 

I told you…this is quite straight forward post….

Till next time

See ya

 

 

8 thoughts on “XRDP- Perform a Custom installation on Ubuntu 15.10 (with Systemd)

  1. typo in line #Issue systemctl command to reflect change and enable the service
    sudo systemctl dameon-reload

    should be daemon (missing the e)

  2. Hi Griffon, This is an amazing script. Everything looks good, however, I am getting an error message on the connection log. I am new to Ubuntu, and using Ubuntu 15.10.

    VNC started connecting
    VNC error – only supporting 8, 15, 16 and 24 bpp rdp connections

    Can you please me with that?
    Thank you

  3. I ran the above script despite having an earlier installation of x11vnc. Should /lib/systemd/system/x11vnc.services and /etc/x11vnc.pass be deleted. At the moment the Windows client refuses to connect. I can however connect with ssvnc.

    Thanks.

  4. Hello KNS,

    What’s the error your getting ? Can you see the xrdp login page ? Can you enter your credentials ?
    Through the XRDP login page, you can select any-vnc or console access. If you connect through this option, are you going through ?
    Possibly the fact that you have a x11vnc.pass file might blocking you in some ways

    Please review logs and check if there is a hint in order to solve the issue

    Hope this help
    Till next time
    See ya

Leave a Reply