How to use Remote Desktop connection against Ubuntu 12.04

Note :

If you are using ubuntu 12.10, please follow the instructions described in this post

 

Hello World,

As you probably know, I like to use remote desktop protocol in order to connect to my ubuntu systems.  By installing a small piece of software called xRDP, you can from windows machines connect remotely to your Ubuntu system using built-in tools (i.e. RDP).  I’ve already explained the process in some previous posts (check here)

With the release of Ubuntu 12.04, the xRDP functionality has been improved but some small issues are still showing up. In this post, we will show you how to

  • easily install xRDP
  • connect to your Ubuntu Unity Desktop Interface
  • set the keyboard layout to be used when using xRDP

Let’s go !

Installing xRDP

The installation is quite straightforward.  Open your Ubuntu Software center and in the search box type xrdp.  You will see something similar to the screenshot.  Click on the install button and wait for the operation to complete.

click on picture for better resolution

 

You are done.  Your system should be ready to accept remote desktop connection

 

Connecting to your Ubuntu machine

If you are lucky…. 

If you remember, I’ve posted some weeks ago a post on how to install Ubuntu 12.04 as a virtual machine on a Hyper-V system.  The first time I’ve tried to use xrdp against Ubuntu 12.04, this is was against this virtual machine.  I’ve simply open the RDP console, put the name (or ip address) of the system to connect to and I was presented with xRDP login box.  I’ve entered the required information (username and password) and I went through with no problems.

click on picture for better resolution

I had a bit of luck because the virtual machine was using ubuntu-2d as desktop environment and that the keyboard layout was set to English.

click on picture for better resolution

 

If you are not lucky…. 

I then tried on a physical machine (and a virtual machine running on virtual box) where the gnome-shell/Unity 3D  interface was loaded.  I didn’t had the same luck. It did not work at first.

First problem I’ve encountered was during the login process through the xRDP session.  I took me five minutes to realize that the xRDP windows was engligh keyboard layout and not the Belgian keyboard layout I was using.

Not a big deal  (for the moment) !  After realizing that, I passed my credential in the xRDP login page and I was able to connect to my Ubuntu desktop….Well, the desktop was there but was empty. Nothing was displayed on it…couldn’t work on it…

click on picture for better resolution

Read on to see how we fixed these issues

Solving the “Empty Desktop Problem”

This problem was quite easy to solve. After some research on google, I’ve found out that I was not the only one having the issue.  The solution was quite simple.  In a few words, you have to force the xRDP software to use the ubuntu-2D (or the gnome-fallback) Desktop environment.  To force that, you will need to create the .xsession file in your home directory and insert the following text in it

gnome-session --session=ubuntu-2d

or you can use a command line to perform exactly the same operation

click on picture for better resolution

This workaround allows you to have a workable desktop. On the other hand, you will be forced to use Ubuntu-2d (this is ok if you have chosen Unity as preferred desktop).  But if you have configured gnome-shell as your preferred desktop, you will not be able to use it. I would say not a big deal, you can remotely connect to your system and in we hope that new release will fix this small issue.

Solving the keyboard Layouts problem in the xRDP session

As mentioned earlier, when you pass the credentials in the xRDP login box, the default keyboard layout is set to english.  When you establish the connection, your remote session will also use the english keyboard layout.  I’ve tried to change it through the system settings… Well did not work….

click on picture for better resolution

Again after some research, it seems that xrdp come with a utility that allows you to change the keyboard layout to be used during the remote session.  You have to perform the operation from your Ubuntu system (not from remote session).  The following screenshot summarizes the commands that needs to be issued.

click on picture for better resolution

 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

Update Feb 2013  

If you still have issues with the keyboard during your xrdp sessions,i.e some special key combinations are not working (ex. Alt+GR), you might want to have a look at this post to see how you could possibly fix it

Final Words

As you can see the xrdp is probably still not the perfect solution for Remote Desktop session but It has the big advantage : you do not need to install any third party tool on your windows/linux machines.  I like this piece of software. It’s really easy to install and you can get it working in minutes.I hope that more development will be performed on this solution so we do not need to tweak anymore (to have it work) and that it will be possible to connect to a gnome-shell or Ubuntu 3D session in the near future.

Note:

  • I found an interesting link on how to compile xrdp and “customize” it a little bit.  If you are interested, you can have a look here (The article covers Ubuntu 11.10)

 

  •  If somebody succeeds in accessing Ubuntu 3D /gnome-shell using xRDP.  Don’t hesitate to share with us. Leave us a comment

Till then

See ya

 

 

 

 

 

49 thoughts on “How to use Remote Desktop connection against Ubuntu 12.04

  1. Great article, but one thing I wasn’t clear on was whether modifying the .xsession file will affect local logins too, or only remote logins?

  2. Hello Dominic,

    The setting should only affect the remote connection through the XRDP. If locally, you are using Gnome shell, this will stay

    Thank for the comment…

    See you soon

  3. Thanks for the article.

    In regards to the keyboard mapping, below is an example how I set it up and it works just fine. fyi, you need to be connected directly to the desktop (no RDP):

    setxkbmap ch

    sudo xrdp-genkeymap /etc/xrdp/km-0807.ini //here is the link for the hex code of other countries http://goo.gl/ULAOk

    sudo chown xrdp:xrdp /etc/xrdp/km-0807.ini

    Hope it helps.

    Cheers

  4. Thanks for the additional information

    and yes (mentioned in the article) the changes has to be performed locally on the ubuntu system and not via RDP.

    Till next time

    See ya soon

  5. FYI:

    Since the demise of unity-2d there’s no way to use unity via xrdp. Indeed, the only way to use xrdp with Ubuntu 12.10 or greater is to install gnome fallback and force loading of gnome fallback in ~/.xsession.

    gnome-session –session=gnome-fallback

    No unity support in the future until xrdp either works with llvmpipe or supports 3D remoting.

  6. I get quite a few failed login attempts. I notice in the logs, there is no ip address of the failed login attemps. Is there a way to force it to log the failed logins so I can block the ipaddress after 3 attempts?

  7. Hello Kbird,

    not that i know…. the sesman file logs sucessful connections but i do not see failed ones
    you might need to use other ways such as enabling logging through your firewall system (if you have one )

    If somebody has an idea in order to log such info… this would be nice to share…

    till next time
    see ya

  8. Hello Kbird,

    there is indeed some xrdp posts coming that will be related to xrdp 0.6. You wanna a teaser. We will explain how to perform a manual install, a scripted installed an perform a basic customizations….

    a first one should be published end of this week…begin next week

    Till next time
    See ya

  9. Is there a way to make xrdp view the same desktop instance as the console and otehr xrdp connections? IOW, if I install a program when I’m connected via xrdp and pin it to the Launcher, the program is not pinned to the Launcher when I login at the console or another xrdp connection.

    In Windows all RDP connections share the same user interface.

    //sergio

  10. Hello,
    i try to install xrdp on my ubuntu but when i want to log from windows, i use my username and password session (ubuntu) but it doesnt work . Could you help me ?

  11. Hello Rachid,

    I might be able to help you if you provide me some more information.

    1.have you installed xrdp on ubuntu 12.04 ? Have you followed the instructions as described on the post. if you are using ubuntu 12.10, check this post at http://c-nergy.be/blog/?p=3518
    2.Have you checked that your keyboard layout is correct when using xrdp (see the post). type your password in the username box and confirm that this is the correct one
    3.Do you have any error message displayed when trying to login (you should have a display box showing the login process…what’is the error message ?

  12. Hello
    Nice post
    I want to connect from a notebook and the keyboard is in the same lenguage but the number and disposal of the keys are diferents

    What can i Do

    Thanks

  13. Hello there,

    can you explain a little bit more ? Are you referring to the keyboard layout ? if you connect via xrdp, the default keyboard layout use english. The post describes how you can change the keyboard layout to match the one you need…

    Hope this help

    See ya

  14. Hello
    i have a PC with a keyboard in spanish with 105 keys . This PC has an Ubuntu 12.04 OS
    I have instaled xrdp and have followed your instructions.
    But I connect from a Notebook with a keyboard (in spanissh too) of 88 Keys.
    And for example in the Notebook when i use the remote desktop to control the PC, the key “del” don’t work, the arrows keys neither.

    Thanks

  15. Hello Miguel,

    This might be due to a limitation of xrdp. XRDP does not support all keys. In fact special keys or combination keys are not working with XRdP. Some peole have tried to fix this issues (and some claimed to have suecceded).

    If you are using special keys or combination keys… the xrdp software will not react to these keys….

    Hope this help

    See ya

  16. Hello

    xrdp does not support all keys. But the keys i am trying to use are not special keys i supose.
    they are the “Del” key and the -> , <- , "arrow up" and "arrow down"

    Thanks anyway, your post helped a lot. I can control allmost all my remote desktop. You solved me the problems of the empty desktop and keyboard layout

    Bye

  17. Hello Miguel,

    these key are not standards… you have to specify them in the km-xxx.ini file you want to use.

    I’m sending you by mail, a km file that seems to work on the spanish keyboard…. I see that there are multiple spanish layout possible (check http://xrdp.sourceforge.net/documents/keymap/rfc1766.html)

    I have found a km file that mach the Spanish Traditional Sort….
    give it a try and let me know if this is working

    this is the list of possible keyboard layouts

    “040A”=”es;Spanish (Traditional Sort)”
    “080A”=”es-mx;Spanish (Mexico)”
    “0C0A”=”es;Spanish (International Sort)”
    “100A”=”es-gt;Spanish (Guatemala)”
    “140A”=”es-cr;Spanish (Costa Rica)”
    “180A”=”es-pa;Spanish (Panama)”
    “1C0A”=”es-do;Spanish (Dominican Republic)”
    “200A”=”es-ve;Spanish (Venezuela)”
    “240A”=”es-co;Spanish (Colombia)”
    “280A”=”es-pe;Spanish (Peru)”
    “2C0A”=”es-ar;Spanish (Argentina)”
    “300A”=”es-ec;Spanish (Ecuador)”
    “340A”=”es-cl;Spanish (Chile)”
    “380A”=”es-uy;Spanish (Uruguay)”
    “3C0A”=”es-py;Spanish (Paraguay)”
    “400A”=”es-bo;Spanish (Bolivia)”
    “440A”=”es-sv;Spanish (El Salvador)”
    “480A”=”es-hn;Spanish (Honduras)”
    “4C0A”=”es-ni;Spanish (Nicaragua)”
    “500A”=”es-pr;Spanish (Puerto Rico)”

  18. Hello Griffon

    Sorry to try your solution with some delay
    It works perfectly.
    even the specials caracters : for example Alt Gr + 2 to get @

    The arrows keys, and the Del key work perfectly.

    I have an “Acer Aspire 1410” with a spanish keyboard and your solution is perfect for its keyboard

    Thanks very much
    Merci Beaucoup.

  19. I’m still fighting with sessions/connections using this method of access. I am logged in now and can see that an app (A VirtualBox VM) is running in a previous session but can’t figure out how to view it. There has to be a way to attach that display to my current RDP session I would hope.

  20. Hello Damon,

    As far as I know, there is no way to connect to the open session (console) in a computer and reconnect to it using xrdp. WHen you connect with xrdp to your remote system, in the login page, you can select your protocol. oone of these protocols is VNC.

    You could use this as long as the vnc server part is configured accordingly to reconnect to your desktop.

    If some people succeeded in reconnecting to console using xrdp, it’s time to share 🙂

    Hope this help
    Till Next Time
    See ya

  21. Just tried out your article (very helpful). One thing I discovered though (and you’re advice on the empty desktop didn’t work until I did this) was that you had to make the .xsession document exectuable using:

    sudo chmod 755 .xsession

    Then I restarted my computer that I wanted to connect to and everything worked great (although It’s a bit slow). People should try this if it’s still not working.

  22. Anyone able to get this to work on Ubuntu 13.04? I am having trouble getting the session to fallback to 2d or classic gnome. Keep getting the error message “failed to load session gnome-classic” … ‘ubuntu-2d’ etc.

  23. Hi Griffin,

    I followed the instructions you have specified. I tried logging in from windows-7 machine and it logged in successfully. But its getting disconnected within a minute. Please advise.

  24. Hello Sreedhar,

    I would check the xrpd log files to see what could be the problem. /var/log/xrdp-xxxx.log
    I would also check that I have the latest drivers installed on the network card
    I would try to perform the operation from a different windows 7 machine and see if the problem occurs or not. if not, the first win 7 might have a problem

    Hope this help
    Till next time
    see ya

  25. Hi Griffon,

    I checked the /var/log/xrdp-sesman.log and found below:

    [20130613-12:06:37] [INFO ] scp thread on sck 7 started successfully
    [20130613-12:06:37] [INFO ] granted TS access to user ent
    [20130613-12:06:37] [INFO ] starting X11rdp session…
    [20130613-12:06:38] [CORE ] error starting X server – user ent – pid 3137
    [20130613-12:06:38] [DEBUG] errno: 2, description: No such file or directory
    [20130613-12:06:38] [DEBUG] execve parameter list: 11
    [20130613-12:06:38] [DEBUG] argv[0] = X11rdp
    [20130613-12:06:38] [DEBUG] argv[1] = :10
    [20130613-12:06:38] [DEBUG] argv[2] = -geometry
    [20130613-12:06:38] [DEBUG] argv[3] = 1440×900
    [20130613-12:06:38] [DEBUG] argv[4] = -depth
    [20130613-12:06:38] [DEBUG] argv[5] = 24
    [20130613-12:06:38] [DEBUG] argv[6] = -bs
    [20130613-12:06:38] [DEBUG] argv[7] = -ac
    [20130613-12:06:38] [DEBUG] argv[8] = -nolisten
    [20130613-12:06:38] [DEBUG] argv[9] = tcp
    [20130613-12:06:38] [DEBUG] argv[10] = (null)
    [20130613-12:06:47] [ERROR] X server for display 10 startup timeout
    [20130613-12:06:47] [INFO ] starting xrdp-sessvc – xpid=3137 – wmpid=3136
    [20130613-12:06:47] [ERROR] X server for display 10 startup timeout
    [20130613-12:06:48] [ERROR] another Xserver is already active on display 10
    [20130613-12:06:48] [DEBUG] aborting connection…
    [20130613-12:06:48] [INFO ] session 3135 – user ent – terminated
    [20130613-12:07:12] [INFO ] scp thread on sck 7 started successfully
    [20130613-12:07:12] [INFO ] granted TS access to user ent
    [20130613-12:07:12] [INFO ] starting Xvnc session…
    [20130613-12:07:13] [INFO ] starting xrdp-sessvc – xpid=3143 – wmpid=3142
    [20130613-12:07:31] [INFO ] session 3141 – user ent – terminated

    I logged in from another Win 7 system and the same problem. And i have the latest drivers. Please advise.

  26. And moreover when I connect from Windows 7, I get a different screen. What i mean to say is, in my ubuntu desktop I have opened up a Terminal, firefox browser, home directory. But when I connect through RDP I get the screen similar to what I get when I login (just the background and Launcher) and it gets disconnected within seconds

  27. Hello Sreedhar,

    Your problem might be related to the vnc package or can be the protocol choice when performing the connection.

    BEst option for you would be to follow the instuctions found in this post http://c-nergy.be/blog/?p=4168.

    You will have to perform an manual installation of xrdp and replace vnc package with X11VNC. Using this approach, you should be able to reconnect to the same remote session (although I’ve never tried to reconnect from a different workstation)

    Hope this help
    Till next time
    See ya

  28. I think there is a typo in step 3 of the instructions to change keyboard layout. It should say 0409 instead of 4090, I guess

  29. If I have no desktop icons to do anything with and no menu, and CTRL+ALT+T doesn’t bring up a terminal, how am I supposed to run any command or do anything!?

  30. Hello there,

    Have you read the post completely ? If you have an empty desktop, you have to create a xsession file specifying which desktop interface you wanna run (ubuntu 2d if you are using ubuntu 12.04 or gnome if you are using ubuntu 12.10 and later). Once this is done, you have a menu bar where you can start your applications….. You can even add desktop icons to your Xrdp session.

    Check also the other posts related to xrdp, you might find some more useful information especially for keyboard layout

    Till Next Time

  31. Ive followed the same steps given above.. i am able to see the desktop from my remote system.. but the user gets logsout in few minutes <2minutes automatically.. i have created new user also.. but it is same

  32. yes
    should be part of the xrdp package.
    simply go to /etc/xrdp and issue the command and this should be working

    Hope this help
    See you

  33. Hello Ben,

    If you see the black/white screen, this is possibly due to the fact that your .xsession file is not populated or not populated correctly or that you do not have installed a proper alternative desktop environment…

    Check this
    which ubuntu version are you using ?? If you are using 12.04, you have to ensure that you are using the ubuntu-2D desktop environment to have it working….
    Check log files for the xrdp and the .xsession process -> look at ~/.xsession-errors.log -> what’s says the file ??
    Check the /vart/xrdp-errors.log also

    What version of the xrdp package are you using ??

    in a terminal, issue the following command $DESKTOP_SESSION -> what do you see as a returned value

    Till next time
    See ya

  34. Excellent article – you saved my day…
    (honestly – you did not save only my day – buy my whole week 😉

  35. Hello Xavier,

    Nice to see that these posts about xrdp are still useful
    Thanks for the visit and the feedback

    Till next time
    See ya

  36. Using a belgian keyboard, 080c, all the modification didn’t work until I modify xrdp_keyboard.ini
    and replace 0813 by 080c
    (debian buster ; mstsc.exe windows 10 )
    Thanks for your job

  37. @Daniel,

    The post is quite old and probably not valid anymore for recent Ubuntu distribution. You should have a look at the most recent posts related to xRDP (check this https://c-nergy.be/blog/?cat=79 or try to use our famous xrdp-installer-1.x.sh script that ease the installation and perform some post configuration actions… please have a look at this page to get the latest version of the script and please read the how to Guide (see at https://www.c-nergy.be/products.html)

    Thanks for the feedback and your positive comments
    Till next time
    See ya

Leave a Reply