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

    it’s seems that you have selected the wrong option in the login xrdp box…
    Can you confirm that you have selected the option sesman-Xvnc in the login xrdp box and try again ?

    Please let us know if this fixed your issue so we adapt the post

    Till next time
    See ya

  2. I fixed it . I needed to uninstall xrdp. install vnc server then re-install xrdp again.
    This worked perfect and I’m all good now … Thanks for prompt reply. ๐Ÿ™‚

  3. Thank you for posting these instructions. They helped me get an xrdp displayback on my Win7 machine.

  4. Hey Diego,

    No problem, always good to see that this post is still working and that people can use them correctly

    Thank for you visit
    Till next time
    See ya

  5. Hello there,
    no problem…We are happy to see that the post is still valid and working
    Thank you for the visit

    Till next time
    see ya

  6. Hi,

    just wanted to thank you for this nice and easy document. Worked like a charm!

    Cheers
    Stefan

  7. Worked like charm.
    About to downgrade to 12.04 for this but this post saved lots of effort.
    Thanks

  8. Hello Anoop,

    Thank you for the visit and for the feedback
    check the post on ubuntu 14.10 where xrdp package has been updated to allow reconnection with no tweak
    Till next time
    See ya

  9. Thanks for putting this together. Saved me a lot of time trying to figure out why Gnome stopped working.

  10. Do you know what this means? After I put in echo xfce4-session >~/.xsession

    -bash: /home/ubuntu/.xsession: Permission denied

  11. hello mike,

    message is quite clear..you do not have the right to create this file….
    I do not know why but you can try again login as the user who needs access to the xrdp solution, open terminal and try again echo xfce4-sesson >~/.xsession
    If this fail, can you try to create the file using the gui under the user home directory…. (Press Ctrl+ H to see hidden files)
    if you cannot create the file, you have a permission issue

    Hope this help
    Till next time
    See ya

  12. Hi folks

    I’ve run though the steps and verified. RDP connects but I still get a grey screen and X pointer. Any ideas what to check? I’m stumped …

  13. Hello Matt,

    Step to do to check your installation
    Step 1 – Connect locally on your ubuntu using the alternate desktop you are using. if working
    Step 2 – Check that xrdp and vnc component have been installed, if this is ok
    Step 3 – check that the .xsession exists and that you do no have any typo in the file name or in the content of the file (-> ths is usually the main reason of the failure)
    Step 4 – Restart your machine and try again

    if this fail, check the logs .xsession-errors.log to see what’s failing

    Check these posts for newer version http://c-nergy.be/blog/?p=6046
    Check the quick demo video and you will see that we are not doing much more that what’s has been written http://c-nergy.be/blog/?p=6063

    Hope this help
    Till next time
    See ya

  14. Thanks. This helped be heaps. It was the alternate desktop thing that was throwing me!
    Glad it wasn’t JUST me that was the problem ๐Ÿ™‚

    Cheers.

  15. Hi, Sir/ Madam,
    am salman i need ur clarification.Now am using xrdpa in working place normaly that Authentication using on ip address e:g(192.168.1.1.) its working.But we need Authenticate using system name e:g(sys1). could u plz explain me how to authenticate system name use to enter….

  16. Hello Salman,
    If I understand your question; you want to use a name instead of an ip address when using the REmote Desktop Client, right ?
    This is actually quite simple, you simply need to enter the name as long as you have a name resolution infrastructure in place. The standard name resolution system is a DNS. So, in your dns, you will need to ensure that the hostname of your ubuntu machine is created and obviously your workstation from where you connect to ubuntu is using the DNS Server you have modified

    You can also use a host file (c:\windows\system32\drivers\etc\hosts) on the workstation from where you connect to ubuntu. If you edit the file; you can add the name and ip address and you should be good to go

    Till next time
    See ya

  17. Thank you for this solution! I am curious if it’s possible to RDP to the current session that has already been running? So, lets say, I log into Ubuntu while sitting at the machine, then I leave the machine and want to RDP into that session from my Windows machine. Your solution uses the port to re-connect, is there a way to find the “port” on an already running instance?

  18. Hello Jim,

    Read the answer till the end….

    To answer your question, no there is no way to reconnect to the console session you have on your ubuntu machine while using xrdp protocol.
    However, you can use a little trick to indeed connect to the console session while using the xrdp software solution. This is a workaround and might not fit your needs but we still provide this option
    Have a look at http://c-nergy.be/blog/?p=5956

    Please read also the following posts (http://c-nergy.be/blog/?p=6046) where you can easily reconnect to the existing session out-of-the box…..

    Hope this help
    Till next time
    See ya

  19. Great post. It’s working good. However. I don;t know why I cannot display properly my terminal emulator, it’s not displaying any characters at all. Do you know how to fix this bug? Thanks.

  20. Hello,

    if you are using xfce, yes there is a small issue with the terminal emulator
    please review the comments to see how you can fix it

    Or you use another terminal emulator or you change xfce terminal preferences

    Hope this help
    Till next time

    See ya

  21. Hello There,

    Thank you for the visit and positive comment
    Do not forget to visit the xrdp section where you might find more useful information

    Till next time
    See ya

  22. The important line is “port=-1”, Thats why xrdp always look for a free port to connect. If you set a fixed port here, the xrdp will always go back and connect to the same session. I changed it in that way:

    [xrdp1]
    name=customsessionname
    lib=libvnc.so
    username=myusername
    password=ask
    ip=127.0.0.1
    port=5912

    Thats it! I You could get away with always changing the port=-1 to port=5912. My xrdp always re-connects to existing session always using the same port.

    See ya
    Michael

  23. Hello,

    Thanks for the post is very useful!
    Everything works ok, but when I try reboot, logout or halt fails… if I restart xrdp works once…
    any help will be appreciated !

    Luis,

  24. Hello Luis,
    Sorry for the late answer but I’m quite busy lately…
    What’s not working….when you perform reboot,logout or halt in the xrdp session ??
    Can you provide info about your configuration…. which desktop environment are you using xfce,mate,lxde,…

    Till next time
    See ya

  25. If you have more then one user on Linux machine for RDP you have to login every user via SSH then:

    1. run any sudo xxx commant and set sudo password
    2. run echo xfce4-session >~/.xsession command

  26. Thank You so much for this information.

    I request you to add information about making changes in /etc/xrdp/startwm.sh file. That was what blocked my path. This file should look like this –
    #!/bin/sh

    if [ -r /etc/default/locale ]; then
    . /etc/default/locale
    export LANG LANGUAGE
    fi

    startxfce4

  27. Further tip

    In xfce4 you may find icons are missing with the minimal install, even after also installing ‘xfce4-goodies’

    Consider adding more of the xubuntu-desktop parts to fix this e.g. discussion at
    http://askubuntu.com/questions/305646/gui-for-ubuntu-server-xfce-or-xubuntu-desktop

    Also, the TAB key may not be working for you due to an xfce4 bug
    https://www.starnet.com/xwin32kb/tab-key-not-working-when-using-xfce-desktop/
    Open the Xfce Application Menu > Settings > Window Manager
    Click on the Keyboard Tab
    Clear the Switch window for same application setting

  28. Hello Minty,

    As you are not using anymore the xfce interface as desktop alternative, we didn’t notice these small issues. Thank you for sharing these tips with us.
    We will try to integrate this information in the next updated post we will write about xrdp installation

    Thank you
    Till next time
    See ya

  29. Thanxz… i got to access a Lubuntu machine with an Android tablet installed with Microsoft Remote Desktop

    and it works like a charm… bizarre

Leave a Reply