Ubuntu 14.04 – How to install xrdp in Ubuntu 14.04

test

 

Hello World,

 

Ubuntu 14.04 has been released on April 17th 2014 and we already released the traditional post about how to perform a fresh install. We didn’t covered the upgrade process because it’s quite easy nowadays. Basically, you will be notified that a new version is available and you will be asked if you want to upgrade to the latest version.

Some readers and some of my colleagues have been asking for a post about XRDP functionality in Ubuntu 14.04. If you follow me, you know that we have been using xrdp package in order to connect to linux machines using the built-in remote desktop client available within Windows Operating System.

You probably also know that since the introduction of Unity Desktop Interface in Ubuntu you need to tweak the configuration in order to have it working. The most annoying part while using xrdp (with Ubuntu) is the fact that you have to install an alternate desktop environment.

So, in this post, we will describe the steps needed in order to install xrdp and the xfce alternate desktop that will be used while remoting into your Ubuntu 14.04 machine.

Let’s Go !

Install XRDP Package from Ubuntu Repository

In this post, we will be installing the standard xrdp package from the Ubuntu Repository. In order to perform the installation of the xrdp package, you will login into your ubuntu 14.04 machine.

Using the Dash button, in the search box, type Terminal

Click on Picture for Better Resolution

Click on the terminal icon and the Terminal console will open

In the Terminal, type the following command

sudo apt-get install xrdp

You will be prompted for your password

Click on Picture for Better Resolution

You will be then informed about the package size. To proceed with the installation, press Y

Click on Picture for Better Resolution

Wait for the completion

When done, you need to install an alternate desktop environment. In our scenario, we are using xfce4

Installing the xfce4 Desktop environment

In the Terminal console; type the following command

sudo apt-get update

sudo apt-get install xfce4

Click on Picture for Better Resolution

You might be prompted for a password.Enter the password and press enter

You will be then informed about the package size. To proceed with the installation, press Y

Wait for the completion

 

Configure xrdp to use xfce desktop environment

At this stage, you have to configure your Ubuntu machine in order for xrdp to know that the xfce desktop will be used instead of the Unity or Gnome (which are not working anymore in Ubuntu). To configure this, from the terminal console, you will issue the following command

echo xfce4-session >~/.xsession

Click on Picture for Better Resolution

Restart the xrdp service by issuing the following command

sudo service xrdp restart

 

Test your xrdp connection

At this stage, you should have a basic xrdp working solution. When I say basic, I mean that you can indeed connect to your remote Ubuntu machine but if you disconnect your session and try to connect again, you will each time open a new session. (Read below section in this post to see how you can reconnect to the same session)

To test your xrdp solution, find the ip address of your linux machine (or use the name if you have DNS Infrastructure in place). To find the ip address, issue the command

hostname -I

Click on Picture for Better Resolution

Now go to your windows machine, start remote Desktop client and enter the ip address/name of your ubuntu machine

Click on Picture for Better Resolution

You should see then the login screen of xrdp presented to you. Note that, at this screen (and because we have not configured keyboard layout yet), the keyboard layout is set to English by default.

Click on Picture for Better Resolution

Enter your username and password and Press OK

You will see a dialog box showing the login process

Click on Picture for Better Resolution

If everything is configured correctly,you should see your xfce desktop loading and you should be able to perform you work through this desktop environment.

Click on Picture for Better Resolution

 

To set Keyboard layout at the xrdp Login screen, perform the following steps

As explained above, with no special configuration, the xrdp login screen keyboard layout is set to english by default.  if you need to change it to another keyboard layout, you should proceed with the following actions

This is the command you should issue in order to change the keyboard layout to be used during xrdp sessions…

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

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

 

Reconnect to the same session throug xrdp

You have mutliple ways to reconnect to the same session through xrdp. we have explained two of them. One method is based on performing a custom installation and use the X11VNC software. This is one is working well but requires a little bit more effort. (http://c-nergy.be/blog/?p=4168)

The other one is to use the xrdp package from ubuntu repository and tweak some configuration files whil connected to the session. This solution is really a workaround and it’s not our favourite one. (see http://c-nergy.be/blog/?p=4471)

Here, we will use a third method that can be used if you use the xrdp pakcage from the ubuntu repository. This method is much better than the one provided by us some time ago. In this method, we will tweak the xrdp login screen. We will add a field in the login box where the user can specify the port to be used when remoting to the ubuntu machine.

You will first need to edit xrdp.ini file located under the /etc/xrdp. To edit the file, issue the following command

sudo gedit /etc/xrdp/xrdp.ini

You might be prompted for a password. if this is the case, provide the password and Press enter
When the file is open, locate the section [xrdp1] and replace the following line

port=-1
with the line
port=ask-1

Save the file. The file should look like this

Click on Picture for Better Resolution

When done, restart the xrdp service by issuing the following command

sudo service xrdp restart.

You are done.

When trying to access your Ubuntu machine through via the remote desktop client, you will see that the xrdp login screen has indeed an additional field called port.

Click on Picture for Better Resolution

If this is your first connection, leave the default value in the port field (i.e. -1), you will be then connecting through xrdp to your ubuntu machine using a specified port that can be seen on the login process dialog box.

Click on Picture for Better Resolution

Take a note of this port.

When you need to reconnect, you will have to specify the same port as your first connection and you should see the same screen as you left it.

Click on Picture for Better Resolution

Note : This tip has been provided to us by one of our reader (Thank you Wei 🙂 )

 

This is it for this post. Using only the ubuntu xrdp package, we have been able to install and configure a remote access solution. By tweaking the xrdp.ini file, we even have been able to provide a simple and easy to use solution in order to reconnect to an existing session.

However, we still have a problem with xrdp used in conjunction with Ubuntu. In order to remote into your ubuntu machine, you have no other choice than using an alternate desktop environment (in our case its xfce). I find it quite irritating that we cannot have the xrdp package working with Unity or Gnome desktop environment.

We have installed fedora distribution and installed the xrdp package. And guess what ! I can connect through xrdp to fedora and have the gnome desktop environment working. Moreover, I can disconnect and when reconnecting I will be reconnecting to the existing session I just left. And all of this with no tweak in configuration files.

I would love to see the same functionality in Ubuntu. As one of our readers mentionned, it might be time for Ubuntu users to fill in a bug report about xrdp and try to have it fixed. If more and more users complains, maybe Ubuntu team will take the request into account.     

 

Till next Time

See ya

 

272 thoughts on “Ubuntu 14.04 – How to install xrdp in Ubuntu 14.04

  1. I am have been wrestling with a keyboard issue for the past couple of days.

    I receive the following errors during an xrdp session:

    QXcbConnection: Failed to initialize XRandr
    Qt: XKEYBOARD extension not present on the X server

    The machine is a VMware VM.

    I performed the steps as suggested:

    # cd /etc/xrdp
    # cp km-0409.ini km-0409.ini.bk
    # setxkbmap –model pc105 –layout us
    # xrdp-genkeymap km-0409.ini
    # reboot

    I still get the same error. Do you have any other suggestions?

  2. @RATT,

    are you executing the commands within your xrdp session -> if this is the case, this will not work…..
    The setxkbmap needs to be run on the machine while logged in locally (and not from xrdp session)
    Which version of UBuntu have you installed ??

    hope this help
    till next time
    see ya

  3. @Nathan

    Wild Guess….. either wrong user name or password…..
    Check that keyboard layout is correct and try again

    Till next time
    See ya

  4. Griffon,
    The instructions here worked brilliantly for one configuration, but when I tried on another configuration to install xfce, I encountered the following messages:

    sudo apt-get install xfce4
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help to resolve the situation:

    The following packages have unmet dependencies:
    xfce4 : Depends: xfwm4 (>= 4.10.0) but it is not going to be installed
    Depends: xfce4-settings (>= 4.10.0) but it is not going to be installed
    Depends: xfce4-panel (>= 4.10.0) but it is not going to be installed
    Depends: xfdesktop4 (>= 4.10.0) but it is not going to be installed
    Depends: thunar (>= 1.6.0) but it is not going to be installed
    Depends: gtk2-engines-xfce (>= 3.0.0) but it is not going to be installed
    Depends: xfce4-session (>= 4.10.0) but it is not going to be installed
    Depends: xfce4-appfinder (>= 4.10.0) but it is not going to be installed
    Depends: xfce4-mixer (>= 4.10.0) but it is not going to be installed
    Depends: orage (>= 4.8.0) but it is not going to be installed
    Depends: libxfce4ui-utils (>= 4.10) but it is not going to be installed
    Recommends: xorg but it is not going to be installed
    Recommends: desktop-base (>= 5.0.4) but it is not going to be installed
    Recommends: thunar-volman (>= 0.8.0) but it is not going to be installed
    Recommends: tango-icon-theme (>= 0.8.90) but it is not going to be installed
    Recommends: xfce4-notifyd but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.

    Am I missing a PPA or repository?

    Albert

  5. @Albert,

    no clue what the problem could be but based on the output you are clearly missing some packages and dependencies…maybe you could use the dpkg command and use the correct switch to have the dependencies fixed….

    Check that you have the last updates on your system (apt-get update …)

    Hope this help
    till next time
    See ya

  6. @Ines,

    Glad to hear that this post helped you…Thank you for the visit and the positive feedback
    Till next time
    See ya

  7. Hi Griffin. Thanks for the post. Do you know if this has been fixed in xUbuntu 16.10?

  8. Thank you very mutch! In contrast to most OS-specific forums your post is really straight forward…

  9. @Stelli,

    Thank you for the visit and positive feedback. It always feels rewarding when a particular post is useful to someone…
    till next time
    See ya

  10. @Orlando,

    xRDP has improved in ubuntu 16.10. To find more info, please visit the xrdp section and look for the version of the operating system you are looking for.
    Ubuntu 16.10 or Xubuntu 16.10 ship with a new version of xrdp package (see http://c-nergy.be/blog/?p=10144)
    If you want a specific installation guide for Xubuntu, please have a look at http://c-nergy.be/blog/?p=10355

    New backend server for xrdp, reconnect to the same session automatically (out of the box)

    Hope this help
    Till next time
    See ya

  11. This might be an old question but some people might still be interested in having a solution for that. Based on your description, the setup seems correct.

    you have installed standard xrdp package sudo apt-get install xrdp
    you have installed an alternate desktop (xfce)
    you have created the .xsession file with the correct information
    Generally speaking, grey screen is because something is wrong with the .xsession file or the user that login

    My guess is that you have done the configuration while logged in with userA but when trying to login via xrdp you are using userB.

    The .xsession file is per user based. If you have multiple users, you have to create for each user the .xsession file with the proper information or you can automate this (for automating check info here )

    So, you have two options :

    Option 1 – login locally on ubuntu (no xrdp) with the userB and issue the command

    – echo xfce4-session >~/.xsession

    Option 2 – have the system create the .xsession file automatically for each user (again full info can be found at here

    Edit the startwm.sh file -> sudo gedit /etc/xrdp/startwm.sh
    Append in this file (just after the word “fi”) the following line
    echo xfce4-session >~/.xsession
    If this is still not fixing your issue, you can have a look in the log files. check for the file ~/.xsession-errors (for the user having the grey screen)

    Please provide feedback if this is working for you

  12. @wancastor696,

    I do not understand your question…
    either you are the single user that needs to connect to the system and you simply create the .xsession file whiled logged on locally on the machine or you have multiple users that will need to connect to the system via xrdp and you should then use the /etc/xrdl/startwm.sh script to generate the .xsession file automatically for each user that will be logged into the system…

    This is working for us..

    More info http://c-nergy.be/blog/?p=6050 (How to enable multiple users in Ubuntu and XRDP)
    Check FAQ as well (even do it’s a little bit out dated – see http://c-nergy.be/blog/?p=5984 )
    Hope this help
    Till next time
    See ya

  13. Three plus years later and the information is still relevant. Thanks for the help getting RDP working on my Ubuntu machine,

  14. I tried all of the steps and when I test the RDP connection from my Windows 10 computer, I get an error “Remote Desktop can’t connect to the remote computer for one of these reasons:

    1) Remote access to the server is not enabled
    2) The remote computer is turned off
    3) The remote computer is not available on the network

    Any help is appreciated.

  15. @William,

    This error seems to indicate that the remote machine is simply not accessible from the network ….

    Can you check that you can ping the remote machine ?
    Can you check that the xRDP service is started ?
    Can you check that the port used by the remote computer are open (no firewall blocking the connection)

    Hope this help
    Till next time

  16. I was struggling getting the RDP to work, but with the soution you provided it worked! thanks 🙂
    I have logged into the console and regenerated xrdp map to latam, most of the keys are working, except arrow keys. Do you know how to fix it?

  17. @David,

    Thanks for the visit and the positive feedback. To try to fix the keyboard, you could try to use the info published in this old post (see http://c-nergy.be/blog/?p=3858)… The post might be a little bit out dated but you can still give it a try on a test machine

    Hope this help
    Till next time
    See ya

Leave a Reply