XRDP – Enable multiple users to connect via xrdp – HowTo Configuration

XRDP_MultipleUsers

Hello World;

I’m back again on XRDP subject and today we will see how you can configure your system in an easy and automated way in order for different users to connect to your Ubuntu machine remotely.

This should be a short post.  The trick has been around for some time now.  We never got the time to explain how you could automatically have the .xsession file created and populated for you by the XRDP server.  So, Today, we will see how you can do this and what are the benefits of such procedure

Ready ? Let’s Go !

.xsession and xrdp Server

If you follow and read our blog on a regular base, you know that we have a lot of information about how to configure and install the XRDP Package on a ubuntu machine.  If you check our last post about xrdp and Ubuntu 14.10, (see XRDP – Reconnect to existing sessions made easier – New xrdp package on Ubuntu repository),  you will notice that before performing a remote connection to the XRDP server, we are creating and populating a file called .xsession

This file is used by the XRDP server in order to know which desktop interface needs to be loaded when a user perform a remote desktop connection.  If you have only one user that needs to access the Ubuntu machine remotely, you will need to perform this operation only once (the creation of the .xsession file)

However, if you have 50 users that needs to access the machine, you will need to create  50 .xsession files (one .xsession file for each user accounts).  This file has to be placed at the “user profile” location. This is not really practical and you would loose a lot of time creating these user profiles.

Hopefully, there is a way to automate the process.  This tip can be used if you have one or multiple users that needs to access to your system remotely via XRDP solution.

Let’s XRDP Server create the .xession file

The trick is quite simple.  The XRDP server is using a bunch of script that runs when a user start a remote desktop connection to the XRDP Server.  We will simply modify one of these script in order to have the .xsession file created just before the user log into the system.

You will need to modify the following file /etc/xrdp/startwm.sh

From a terminal console, type the following command

sudo gedit /etc/xrdp/startwm.sh

you will be prompted for a password.  Type in the password.  If everything goes well, you will see the content of the startwm.sh file.

after the fi section add the following line

echo mate-session >~/.xsession

and save it

Note :

In our example, we have installed the mate-desktop interface.  This is why we add the line echo mate-session (…).  If you have installed another alternate desktop (like xfce), you have to insert the correct command in the startwm.sh file (ie echo xfce4-session >~/.xsession) 

Click on picture for better resolution

If needed, you can restart the xrdp service issuing the following command sudo service xrdp restart  and you should be good to go.

Final Notes

Voila Voila !  We have successfully automated the creation of the .xsession file by modifying the startwm.sh script.  If you have multiple users defined on your ubuntu machine, you can now have them connecting to the xrdp server and they will get access to their remote desktop session. You, the administrator of the system, didn’t create the .xsession file for each user, the xrdp server (and the startwm.sh) script did the work for you.

In the future post relate to xrdp, we will be using only this way of creating the .xsession file simply because it’s easier and more effective that creating the file manually

Till next time

See ya

6 thoughts on “XRDP – Enable multiple users to connect via xrdp – HowTo Configuration

  1. This process works but its an issue if the second account is not given ssh capability. If we do not give sudo power to second account then their is an authentication prompt and the workspace of xfce is un-usable.

  2. Hello Rog,

    seems strange to us.. we never grant ssh rights to any users and people can login with no issues….
    We will have a look at it and see if indeed, we need to update the post and mention the ssh capability

    Thank for the visit and sharing the info….
    will investigate further

    till next time
    See ya

  3. It’s actually a workaround. What if some users prefer other sessions?
    see `man xsession` search ‘determine-startup’
    You can use /usr/bin/x-session-manager symlink pointed to e.g. /usr/bin/startlxde. This symlink is managed by alternatives. So all you need to do is:

    update-alternatives --config x-session-manager

    or (to set it without interaction):

    update-alternatives --set x-session-manager /usr/bin/startlxde

    Don’t forget to remove .xsession files from home folders, cause that files override global setting.
    worked for me on Ubuntu 14.04 LTS, See ya

  4. Hi,

    I am trying to create multiple user accounts on Ubuntu 14.04 with sudo rights. I also need to setup remote desktop so taht all users may login remotely to their saved sessions. I followed the steps here:
    http://c-nergy.be/blog/?p=6050
    http://c-nergy.be/blog/?p=5874
    However, I am unable to save the sessions and the screen goes blank after a few seconds.
    Also, when I try to login remotely through xvnc, i see the following message after 3-4 minutes:
    sesman connecting ok
    sending login info to session manager, please wait…
    xrdp_mm_process_login_response: login successful for display
    10
    started connecting
    connection problem, giving up
    some problem

    Would you know the solution to this problem? Its surprisingly frustrating.

    Thanks.

  5. Hello Sanjana,
    Sorry for the delay but I’ve travelling abroad and I have really limited time and infrastructure
    Please check already the log files to see what could be the problem (please review this post -http://c-nergy.be/blog/?p=5984. It should provide you a starting point.
    I will have limited availability in the coming 7 days. If you have time till then, I can then try to have a look at it

    Till next time
    See ya

Leave a Reply