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

systemD_Logo1

Hello World,

We are back on Ubuntu and xrdp topic.  Since Ubuntu 15.04,  the operating system has replaced the Upstart components with the Systemd component.   Systemd can manage Ubuntu services.  This change in the operating system can affect the way your system is working.  Previous instructions on how to have a service starting at boot up might not be valid anymore since the way the operating system is handling this in a different way.

A good example of such situation is when you perform a custom installation of xrdp.  Prior to Ubuntu 15.04, you could use the instructions and the script provided at this location. Since Ubuntu 15.04, if you perform a custom installation of xrdp, this procedure will fail and you will not be able to use xrdp accordingly.

However, in our previous post, we have quickly described a workaround in order to have xrdp software working if you have performed a custom installation.  The workaround is quite simple. You simply need to delete the xrdp.service and xrdp-sesman.service file used by the systemd software and you should be able to connect again to your ubuntu machine via XRDP.

In this post, given that Ubuntu 15.04 is now using Systemd solution, we have decided to update the install-xrdp.sh script.  Using this script, you will be able to perform a custom installation and have xrdp running perfectly fine.  Moreover, we have updated the xrdp.service and xrdp-sesman.service Units files used by systemd in order for to have the xrdp service managed and controlled properly by systemd.

Let’s do this….

Why a custom installation ?

We are performing and testing custom installation because we can use the bleeding edge version of xrdp. Ubuntu is using package 0.6.xx which is fully supported by the team behind xrdp.  With the custom installation, we will be using the package 0.9.xx. We wanna see the progress made by the team and see how the solution is evolving.

The custom installation will also configure the system to always reconnect to the same session. This element is of less importance since Ubuntu has updated the xrdp package and since you can reconnect to the same session with no additional configuration.

The Updated Script (version 1.4)

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). We have updated the script to take into account the introduction of systemd component in Ubuntu 15.04.   In this updated version of the script, we are modifying the xrdp.service and xrdp-sesman service so they reflect the correct path of the executable files for the xrdp service.

The script

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

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 installat 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 dameon-reload
sudo systemctl enable xrdp.service

echo “Restart the Computer”
echo “—————————-”
sudo shutdown -r now

Set Execute rights on the script

You can copy/paste the script into a text file in your home directory and save it as xrdp-install.sh.  In order to be able to run this script, you will need to make the script executable.  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

Here, what you want to test is that you can effectively reconnect to the same session.  To test that, you will connect a first time to your remote Ubuntu machine, open some applications and then disconnect.  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

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

This is it for this post.  The process to perform a custom xrdp installation remains basically the same.  The only thing we had to change was path of the executable file for xrdp in the /lib/systemd/system/xrdp.service and /lib/systemd/system/xrdp-sesman.service to reflect the correct location in Ubuntu.  After that, we were able to have xrdp running properly.  You can now use the systemctl start xrdp or systemctl stop xrdp or even systemctl status xrdp commands to check and manage the xrdp service.

Till next time

See ya

21 thoughts on “XRDP- Perform a Custom installation on Ubuntu 15.04 (with Systemd)

  1. Hi, I am running Ubuntu-mate.org 15.04 for Raspberry pi 2. So I already have Mate desktop. I have already installed X11vnc and can use it. For performance reasons I want to use rdp too.
    I am trying to apply only the parts of your script that I seem to need:
    install/remove stock xrdp to create startup service: this brings vnc4server and xbase-clients, which are not removed; moreover: after the remove xrdp there are no xrdp entries in /lib/systemd/system.
    How should I continue?

  2. PS: “sudo systemctl dameon-reload” must probably be: “sudo systemctl daemon-reload”

  3. PS4 mmm, my single quote is rendered as ‘ which, when copied, will not be recognized as a single quote…

  4. PS5 Guess “sudo cp /etc/xrdp/rsakeys.ini /usr/share/doc/xrdp/rsakeys.ini” must be “sudo cp xrdp/rsakeys.ini /usr/share/doc/xrdp/rsakeys.ini” as xrdp/rsakeys.ini does not (yet?) exist in my /etc. I suppose you intend to copy the source file as a documentary example.

  5. yes, sed use quotes
    if you simply copy/paste, you might have different characters because of font formating used by the blog

  6. did you succeed in performing your installation….?

    If yes, can you share your findings for other people that might want to perfom same kind of installation….

    hope this help
    till next time
    see ya

  7. It works (mostly) :):).

    Installed stock-xrdp: sudo apt-get install xrdp –no-install-recommends then removed it.
    downloaded latest xrdp from github.com/neutrinolabs; after solving the sed problem and pkg-config it installed with that part of your script.
    I added address=127.0.0.1 in the global section of xrdp.ini to bind xrdp to localhost. I connect through ssh-tunnel. x11vnc is started also with the -localhost option. So much for security.
    It is indeed faster than mere vnc.

    Currently working om special keyboard problems: when connecting from android (swipe) or laptop (nl-keyboard), I encouter problems, especially with the special characters in passwords (:(:(: Connecting from windows-pc with PuTTY and mstc.exe (!!! do not use port 3389 but 33389 for instance) works flalessly.

    Your blog a great help and very instructive.

    Here another link that opened my eyes for simple xrdp x11vnc communication:

    http://forum.odroid.com/viewtopic.php?f=52&t=4489

    Thanks and good luck and maybe you can help me with the (android)-keyboard problems…

  8. PS: rsakeys.ini is needed in /etc/xrdp; I preferred to create my own with xrdp-keygen command. deleted the stock version and created link with: sudo ln /etc/xrdp/rsakeys.ini /usr/share/doc/xrdp/rsakeys.ini

    Systemd readahead looks for it there during boot. For that reason I also made:
    sudo ln /usr/local/sbin/xrdp-sesman /usr/sbin/xrdp-sesman
    sudo ln /usr/local/sbin/xrdp /usr/sbin/xrdp

    (try cat /var/log/syslog | grep xrdp )

  9. hey thank you Benoit,

    if we have time, we will try to cover xrdp and raspberry devices

    till next time
    see ya

  10. Thanks for this wonderfull script Griffon 🙂
    There were only a few typos, when correcting them it works like a charm 🙂

    ################################################################
    # Script_Name : xrdp-install.sh
    # Description : Perform an automated custom installat 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 daemon-reload
    sudo systemctl enable xrdp.service
    sudo systemctl enable xrdp.service

    echo “Restart the Computer”
    echo “—————————-”
    sudo shutdown -r now

  11. Hello There,

    My colleague checked the script and didn’t find real typo. The problem you might encounter is the formatting (there is even a note just before the script). The html formatting might not be recognized by your text editor and the script might not work as expected.
    You have indeed to check/slightly modify some characters to have it working

    As soon as I have some time, I will check the script again and possibly offer a download with a proper formatted text

    Thank for feedback and improving the quality of the information provided here

    Till next time
    See ya

  12. I’m on 16.04.. and found that your buildchain was missing the nasm assembler package too.. (as reported by .configure). Adding “nasm” to your buildchain package list fixed it for me.

    T.Weeks

  13. Hi,

    We used windows server to connect our environment through RDP. inplace of windows we want to use Linux.
    I have installed linux ubuntu18.04 desktop version and tried to connect through RDP. But i am getting below error in blue screen
    —————————————————————–
    Connecting to sesman ip 127.0.0.1 port 3350
    sesman connect ok
    sending login info to session manager, please wait
    login successful for displaying 10
    started connecting
    connection problem giving up
    some problem
    ——————————————————————
    can you please provide me the resolution asap.

    can you please let me know shall we login multiple users to ubuntu desktop version. and can you please provide the what are the packages need to install on the ubuntu desktop18.04.

    Thanks and regards
    praveen

  14. @Praveen

    Thank you for visiting our blog. First, you are referring to a quite old post about xRDP and Ubunt u15.04. The script presented in this post is obsolete and has been replaced by a new version of the script….
    Please visit the following page https://www.c-nergy.be/products to see all the latest version of the script…. For Ubuntu 18.04, please follow instructions found at http://c-nergy.be/blog/?p=14888

    Hope this help
    Till next time
    See ya

  15. @ Giffon,

    Thanks for your prompt response. I would never expect this. really great for your support i will try and let you know .

    Thanks
    Praveen

Leave a Reply