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