Ubuntu – Getting a working remote desktop server running on Ubuntu 14.04

terminal-serverUbuntuxdmcp

OK – here is something that I have had working a ton of times in the past – an XDMCP enabled X server that serves nice and shiny sessions including a login handler.

What I have:

  • A virtual Ubuntu machine running on ESXi – I want this machine to be a like a Windows Terminal Server.
  • A working VNC setup via x11vnc – this is OK if you have a running sesion, but not if you want to login and create a new session. Also – quite messy on a multi user box
  • A lot of experiments with lightdm and gdm, trying to get the XDMCPfunctionality up and running. Editing /etc/lightdm/lightdm.conf and /etc/gdm/* is working to some extent. I can get the login manager running via lightdm, but once logged in, the user is just left hanging with no session to play with.

In lightdm (which is where I am at right now), my lightdm.conf has this:

[SeatDefaults]
allow-guest=false
[XDMCPServer]
enabled=true
port=177

There are some things here I think I am just not getting – this is where I'd like some really super answers:

  • XDMCP still lives (via SSH or not) even though it is sort of old and grey. Is there something new (like a new protocol) I don't know about that I should be using instead?

  • Is the user base for this sort of thing shrinking and should I be employing a different strategy? I really don't want to because I like terminal servers.

And – this is of course the answer I am really looking for:

  • Can someone point me to the exact spots in the gdm or lightdm config files that need to be changed in an otherwise completely default Ubuntu 14.04.2 Desktop edition (64 bit)?

I realize there are projects like LTSP out there, but this is not what I want, since I don't want my clients to boot into a Ubuntu setup or anything – they just need to be able to log in same as if they were using Remote Desktop to start a Windows session. I am really feeling quite dejected at this point – I had this working super smooth ten years ago, but now a working solution completely eludes me.

Best Answer

OK - so I figured it out finally. As @gnur suggests, xrdp is the thing to use, but not right out of the box. It appears that the XRDP that comes with Ubuntu is old(ish), so:

  • XRDP must be built from source. Get the source here and follow the very nice manual here to get things in reasonably working order. Without this, session reconnection does not work which is a bit of a show stopper.

I have done a couple of extras to get things completely in shape:

  • XRDP does not work as other X things do with xmodmap, so if you keyboard is not working as you want it to in an XRDP session, you have to:
    • Log on to a real console session (i.e. not via XRDP, but maybe via the ESXi console or physically) and adapt things to your keyboard layout in that session. Try setxkbmap -model pc104 -layout <your-layout> (dk in my case)
    • Then dump the working layout to an .ini file that XRDP can load. Do this: xrdp-genkeymap mymap.ini
    • Figure out what to actually name the file by looking at /var/log/xrdp.log look for something like local keymap file for 0x0406 found. Then name your file /etc/xrdp/km-0406.ini. That took a while to figure out.
  • Modify your /etc/xrdp/xrdp.iniso you have a session description that looks like this: [xrdp1] name=sesman-Xvnc lib=libvnc.so username=ask password=ask ip=127.0.0.1 port=-1 delay_ms=2000 The key parts are lib and delay_ms - without the delay, I got no desktop after logging in to an XRDP session. It seems the underlying VNC session takes a little while to get ready and if connections are attempted too soon, you get nothing.
  • Put something sensible in your ~/.xsession file. I have xfce4-session but that came with another oddity - tab completion in terminal windows did not work. Apparently, XFCE uses the tab key for window switching. To fix this, you need to edit (maybe there is a GUI thing too) ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml and apply the fix described here.

That is it! With this running, I have a very nice replacement for XDMCP that lets users treat Ubuntu sessions as they do Windows sessions. Just as I wanted :-)

EDIT having used this a while, I have found the solution to be workable but not that stable. From time to time, the session reconnection will not work and users will be left in a limbo state, unable to log on at all. Restarting the services fixes this, but it doesn't really hold up.

So - I looked some more for a working solution - and found one! My new best friend is x2go, which is a standalone X server with a special client package that comes in several OS flavors.

EDIT 2: OK - so even more about this. I found that while X2go is quite nice, the Windows client has a quirk that pretty much stops it from working with key based SSH logins, so I have had to enable regular PW logins for my desktop host. Not optimal, but it does not change the fact that X2go works really well in all other respects.

EDIT 3: Scarygliders has a very nice script at this point that gets, compiles and installs everything needed for a shiny RDP session setup. I pretty much eliminates the need for the other stuff I found. Get the scripts here by cloning. Then run X11rdp-o-matic.sh --justdoit. I now have a desktop host that services five users all doing Python development and such. Very nice.