XRDP – Quick fix – Custom XRDP install on Ubuntu 15.04 using systemd

QuickFix_xrdp1

Hello World,

Ubuntu 15.04 has been released end of April 2015 and one of the major change in this release was the move from Upstart to systemd solution. Since this change has been introduced, some of our users have noticed that the xrdp service is not starting or working properly.

In this post, we will provide you the instructions in order to fix your custom xrdp installation and have it working with systemd software.

When to use this fix ?

If you have performed a custom installation of xrdp on ubuntu 15.04 using the install-xrdp.sh script (version 1.3) found at XRDP- Perform a Custom installation on Ubuntu 15.04,  chances are that you cannot start your xrdp service anymore.   You will need to follow the following instructions in order to have your xrdp service working again.

The Problem

If you have installed Ubuntu 15.04 and didn’t change anything, the Upstart component has been replaced by the Systemd component. Systemd component will be managing your services on your Ubuntu system.   If you have installed xrdp using the instructions found on this post (XRDP- Perform a Custom installation on Ubuntu 15.04), chances are that you are not able to start the xrdp service.

If you issue the following command from a terminal

sudo service xrdp restart

the following error message would be returned

A dependency job for xrdp.service failed. see journalctl -xe for details

XRDP_systemD_1.png

Click on Picture for better Resolution

if you type, journalctl -xe, you will see the following output..

XRDP_systemD_2.png

Click on Picture for better Resolution

To have it more readable, we have put the output into a text file.

XRDP_systemD_3.png

Click on Picture for better Resolution

You can see that indeed the xrdp service has failed to start and that the systemd is basically complain about “environmnent files not found”

 

The Troubleshooting Steps

After reading a little bit about systemd and upstart (check this link  https://wiki.ubuntu.com/SystemdForUpstartUsers),  we went to have a look into the following directory

 /lib/systemd/system

We have found the two files that are controlling the xrdp service (xrdp.service and xrdp-sesman.service)

XRDP_systemD_4.png

Click on Picture for better Resolution

We have edited the xrdp.service file and it looks like this

XRDP_systemD_5.png

Click on Picture for better Resolution

If you look at the screenshot, you see that the file has an entry called EnvironmentFile=/etc/sysconfig/xrdp.   

We have noticed this line immediately because in Ubuntu there is no /etc/sysconfig folder.  So we have assumed that the content of these two files were generating the errors.

To solve this issue, we can provide two different ways

  • a quick and simple fix
  • a better solution that make xrdp and systemd working together

The Quick Fix

As explained above, the content of the xrdp.service and xrdp-sesman.service files does not seems to reflect the correct information about path location for executable files and Environment file.  To quickly solve the issue, we can decide to delete the xrdp.service and xrdp-sesman.service files from the /lib/systemd/system folder.

Restart you ubuntu system and you should be able to access your system via xrdp software solution.

By removing these files, you actually saying to systemd to use the old/backward compatible init script method.  You should be able to start your xrdp service with no issues.  You can even execute the following command to see the status of xrdp service

sudo systemctl status xrdp

and you will see that the service is marked as active

XRDP_systemD_6.png

Click on Picture for better Resolution

Note : Set correct permissions on the xrdp log files

If you try to restart the xrdp service just after removing the xrdp.service & xrdp-sesman.service files, you might see a message error stating that log file cannot be open and xrdp service fails to start.  You simply need to ensure that the xrdp files under /var/log/ can be read and write by the root account. (We encountered this issue and solved it in this post http://c-nergy.be/blog/?p=4168 – Minor changes sinces… section)

 

The Proper Fix

If you want to have systemd really managing the xrdp service, the proper fix here is to update the content of the xrdp.service and xrdp-sesman.service files. As mentioned above, these files contain information about path that does not apply to ubuntu.

xrdp.service file

The xrdp.service file should contain the following information.  copy/paste the text below into the /lib/systemd/system/xrdp.service file and save it.  You need to use sudo command in order to be able to modify this file.((i.e. sudo gedit /lib/systemd/system/xrdp.service)

[Unit]
Description=xrdp daemon
Requires=xrdp-sesman.service
After=syslog.target network.target xrdp-sesman.service

[Service]
Type=forking
PIDFile=/var/run/xrdp.pid
#EnvironmentFile=/etc/sysconfig/xrdp
ExecStart=/usr/local/sbin/xrdp $XRDP_OPTIONS
ExecStop=/usr/local/sbin/xrdp $XRDP_OPTIONS –kill

[Install]
WantedBy=multi-user.target

 

xrdp-sesman.service file

The xrdp-sesman.service file should look like the one below.  Copy/paste the text below into the /lib/systemd/system/xrdp-sesman.service file and save it.  You need to use sudo command in order to be able to modify this file. (i.e. sudo gedit /lib/systemd/system/xrdp-sesman.service)

[Unit]
Description=xrdp session manager
After=syslog.target network.target
StopWhenUnneeded=true

[Service]
Type=forking
PIDFile=/var/run/xrdp-sesman.pid
#EnvironmentFile=/etc/sysconfig/xrdp
ExecStart=/usr/sbin/xrdp-sesman $SESMAN_OPTIONS
ExecStop=/usr/sbin/xrdp-sesman $SESMAN_OPTIONS –kill

[Install]
WantedBy=multi-user.target

 

Using systemctl to apply changes

The final step here is to issue the following command because we have modified the service units files of XRDP.  Systemd needs to know about these changes.  From a Terminal session, you will issue the following command

sudo systemctl daemon-reload

sudo systemctl enable xrdp.service

 

Reboot your system and check that the xrdp service is starting properly.  If this is the case, you should be able to perform an xrdp connection and you are back on track.

 

Final Notes

With the introduction of systemd in Ubuntu 15.04, we have encountered a small issue with the custom installation of xrdp.  Because of the change in the way the services are managed in Ubuntu 15.04, we need to update our install-xrdp.sh script to take into account the fact that systemd is now the component that will be controlling the xrdp service.  As we already found what was the problem with the service unit files, you can expect to have the new installation script ready in the next post.

 

Stay tuned

Till next time

See ya

 

 

 

 

 

 

 

 

14 thoughts on “XRDP – Quick fix – Custom XRDP install on Ubuntu 15.04 using systemd

  1. I have just upgraded from 14.10 to 15.04 and was having this problem. I resolved it a different way before I found this post.

    What I actually did was install upstart and replace systemd. This allowed xrdp to run as it did before as well as resolving other issues I was having.

    I now have a very odd issue though, which I’m unsure how to fix. When I log in with my username using windows remote desktop, it loads up the mate desktop and all my icons, but there are no toolbars at the top or bottom and the icons are periodically jumping up and down. It’s basically unusable.

    The really odd thing is though is that my linux server has other user accounts, when I log into one of those everything works fine.

    I don’t suppose you have any suggestions as to how I might fix this do you?

    Many thanks,
    Chris

  2. Hello Chris,

    IF I understand correctly, only one user account has the issue while connecting through xrdp, Right ?
    If this is the case, my first guess would be that the mate saved sessions file is corrupted or broken. Try to reset the saved session for the problematic user….
    Check this link to have more information and location of the files that you might need to check
    http://manpages.ubuntu.com/manpages/utopic/man1/mate-session.1.html

    You can also check the file ~/.xsession-errors to see what might be the issue…

    worst case scenario, you will need to reset the settings for the Mate Desktop Session -> google for it to see how to perform such actions and the side effects of such operation

    Hope this help
    Till next time
    See ya

  3. Hi Griffon,

    Many thanks that’s really useful advice. I actually managed to discover what the problem was last night with some stabbing around in the dark.

    It turned out that when I was fixing some other unrelated problem, a bunch of the files in my home directory had had their ownership changed to root. Once I used chown recursively on my home folder and restored ownership everything started working a treat. It was a very strange error though, the icons would jump around in a seemingly random pattern, nothing to indicate a file access problem…

    Many thanks,
    Chris

  4. I don’t know if its just my Ubuntu 15.04 system but on mine xrdp is located in /usr/sbin … not … /usr/local/sbin.

    So I changed those paths in the 2 systemd scripts:
    xrdp.service
    and
    xrdp-sesman.service

  5. Hello there,

    You are right… we have made a typo while publishing the info…. if you look at the screenshot above. We are providing the correct path information
    Sorry about.. We will update the info as soon as possible

    Thank you for notifying us

    till next time
    see ya

  6. Thanks for this….

    I have a more serious concern, going forward. Actually two concerns:
    XRDP relies on XWindows being present, afaik, and Ubuntu is moving away from Xwindows with Mir. Will XRDP have to be rewritten to work with Mir? any effort from Canonical to rearchitect XRDP to work atop Mir? or change it to MirRDP so to speak?

    Concern number two: the page os XRDP hasn’t been updated in two years. What is going on here? was XRDP the work of a single developer, and he died, or what? if there were multiple devs, what happened with them? were they all together when their plane went down? 😉

    In short, I’m a little concerned that if I create a working setup with XRDP that sooner rather than later it will end working due to code rot.

    Perhaps you’re more informed than me up there and can shed some light on the status of XRDP and or its devs.

    Thanks for providing this post.
    FC

  7. Hello Fernando,

    We do not know if xrdp will work with the MIR display but as far as we can tell this will still take some time before the MIR will be introduced and you will still have a co-existence period which leave you plenty of time to find for alternatives

    The official xrdop web site is not really often updated but deveolpment is stil ongoing via github (chekc https://github.com/neutrinolabs/xrdp)

    hope this help
    till next time
    see ya

  8. I changed the scripts for xubuntu 16.04 and it somewhat worked after changing the 2 files but all the menus and panel icons were gone making it unusable. Then I changed the paths as suggested and the connection immediately crashes both the connection and remmina! Please help I need this working to support 12 xubuntu 16.04 computers at our local library. I should have never upgraded from 14.04 to 16.04 as it is ridiculously buggy, not at all what I would expect from a LTS upgrade.

  9. @cmcanulty

    I will try to have a look on this but as I’m really busy with heavy projects..You would need to wait 2/3 days before I come back to you
    In the mean time, can you perform some basic tests ?
    Can you install a xubuntu 16.04 from scratch
    Install the xrdp package
    edit the file /etc/xrdp/startwm.sh
    and add after the fi line
    xfce-session
    Restart your system

    Can you tell me what’s the status with such configuration ? is it working ?

    Till next time
    See ya

  10. @cmCanulty,

    Hello there, we have performed a basic installation of Xubuntu

    Instructions

      We have then installed xrdp (sudo apt-get install xrdp) and that’s it !!!
      We were able to remote desktop immediately

    If you are using the script from scarygliders to have xrdp running, you will need to check with the author of the script. Googling a bit we have discovered that the script didn’t work properly on Ubuntu 16.04 and work is being done in order to fix the issue (check this link

    Now; it’s up to you to decide what to do

    Try to install from scratch new xubuntu 16.04 machine and install the instructions provided in this comment to install xrdp the easy way
    Try to remove the scaryglider package and fall back with the easy install of xrdp using instructions contains in this comment

    Hope this help
    Till next time
    See ya

  11. Staff Hello, I saw the script you and decided to test the Ubuntu Mate 16:04, but did not work, so I went behind the problem and saw it had some mistakes, so I installed a Ubuntu Kill 64 16:04 scratch, and nothing else, just ssh service, following my script it works!

    # apt-get 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
    # git clone git://github.com/neutrinolabs/xorgxrdp
    # git clone git://github.com/neutrinolabs/librfxcodec
    # git submodule init
    # git submodule update
    # cd librfxcodec
    # ./bootstrap
    # ./configure
    # make
    # make install
    # cd..
    # cd xorgxrdp/
    # ./bootstrap
    # ./configure
    # make
    # make install
    # cd ..
    # ./bootstrap
    # ./configure –enable-fuse –enable-rfxcodec –enable-fuse –enable-jpeg
    # make
    # make install

    Editar os arquivos:

    # nano /lib/systemd/system/xrdp.service
    [Unit]
    Description=xrdp daemon
    Requires=xrdp-sesman.service
    After=syslog.target network.target xrdp-sesman.service
    [Service]
    Type=forking
    PIDFile=/var/run/xrdp.pid
    #EnvironmentFile=/etc/sysconfig/xrdp
    ExecStart=/usr/local/sbin/xrdp $XRDP_OPTIONS
    ExecStop=/usr/local/sbin/xrdp $XRDP_OPTIONS –kill
    [Install]
    WantedBy=multi-user.target
    -> xrdp-sesman.service
    # nano /lib/systemd/system/xrdp-sesman.service

    [Unit]
    Description=xrdp session manager
    After=syslog.target network.target
    StopWhenUnneeded=true
    [Service]
    Type=forking
    PIDFile=/var/run/xrdp-sesman.pid
    #EnvironmentFile=/etc/sysconfig/xrdp
    ExecStart=/usr/local/sbin/xrdp-sesman $SESMAN_OPTIONS
    ExecStop=/usr/local/sbin/xrdp-sesman $SESMAN_OPTIONS –kill
    [Install]
    WantedBy=multi-user.target

    # systemctl enable xrdp.service
    # systemctl enable xrdp-sesman.service
    # systemctl daemon-reload

    obs: the script is in Portuguese-br because I am Brazilian and I never give up!
    See you!

Leave a Reply