Xubuntu Remote Desktop

At Sand Port we made a media center out of my Xubuntu ThinkStation. Now we have an easy central place for listening to tunes and watching fireplaces.

We’re a pretty lazy bunch, and often fiddling with laptops while something is on the TV. Wouldn’t it be great if we could control the media center without even lifting our hands from the keyboard?

I want to make it easy for others, so setting up an RDP server seemed like the best solution. Windows has a built-in RDP client so my flatmate wouldn’t have to install any software.

To make this work in Xubuntu I used xrdp and vino on the server, and on the testing client I used nmap, freerdp and remm1ina.

Mapping the network

The first step is find the media center from my laptop.

Use nmap -sn (ping scan) to find hosts on the local network.

$ nmap -sn 192.168.0.1-254

Starting Nmap 6.40 ( http://nmap.org ) at 2014-04-01 21:41 BST
Nmap scan report for 192.168.0.1
Host is up (0.020s latency).
Nmap scan report for 192.168.0.6
Host is up (0.043s latency).
Nmap scan report for 192.168.0.10
Host is up (0.000067s latency).
Nmap done: 254 IP addresses (3 hosts up) scanned in 3.38 seconds

http://linuxcommando.blogspot.co.uk/2008/05/ping-or-nmap-to-identify-machines-on.html

Three IPs: 1 is the router, and 6 and 10 are my media center and laptop. Which way round, though?

I ran ifconfig at the media center to find out its own IP address.

$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:21:86:fa:f0:45  
          inet addr:192.168.0.5  Bcast:192.168.0.255  Mask:255.255.255.0
[...]

The output tells me I can use 192.168.0.5 to refer to it on the local network.

Enable RDP on the server

Setting up the actual RDP server is as simple as installing a package.

sudo apt-get install xrdp

The default port for the RDP protocol is 3389.

Check just this port using nmap on the laptop.

$ nmap 192.168.0.5 -p 3389

Starting Nmap 6.40 ( http://nmap.org ) at 2014-04-01 22:25 BST
Nmap scan report for 192.168.0.5
Host is up (0.0039s latency).
PORT     STATE    SERVICE
3389/tcp filtered ms-wbt-server

Nmap done: 1 IP address (1 host up) scanned in 0.49 seconds

Previously I locked down the media center ports using the gufw firewall. I made an exception for all incoming connections on port 3389.

gufw rule

Now the port is open.

$ nmap 192.168.0.5 -p 3389

Starting Nmap 6.40 ( http://nmap.org ) at 2014-04-01 22:45 BST
Nmap scan report for 192.168.0.5
Host is up (0.0031s latency).
PORT     STATE SERVICE
3389/tcp open  ms-wbt-server

Nmap done: 1 IP address (1 host up) scanned in 0.49 seconds

Start a new RDP session

Install freerdp on the laptop. It’s a command line RDP client.

sudo apt-get install freerdp-x11

Use freerdp to connect to the media center on the default port.

xfreerdp 192.168.0.5

Got a log in screen. So far so good.

freerdp login

Log in as sandport.

Login appears to be successful, but all I see is a blank screen. Rubbish.

blank remote desktop

You have to put the name of the desktop manager in a file called .xsession in the sandport home directory.

echo "xfce4-session" > .xsession

http://c-nergy.be/blog/?p=4448

Try again. Success!

remote desktop success

Some of the icons look wrong, but I can live with that.

The main issue is that this actually creates a new desktop session. What I really want to do is share control of the existing desktop so I can queue stuff up on Spotify.

Sharing the main desktop

Ubuntuwiki has a guide to desktop sharing with Xrdp that contains almost everything I needed.

http://askubuntu.com/questions/235905/use-xrdp-to-connect-to-desktop-session

http://ubuntuwiki.net/index.php/Xrdp,_installing

Back to the server to install vino, a desktop sharing server for VNC. This works because xrdp actually uses VNC on the server and talks to clients using RDP.

sudo apt-get install vino

Unfortniately I saw this error because Vino doesn’t start automatically on XFCE.

“connecting to 127.0.0.1:5900 error – problem connecting”

To make it start in XFCE you have to add XFCE to the list of desktops in the autostart file.

The autostart file is here:

/etc/xdg/autostart/vin-server.desktop

You have to change the line with OnlyShowIn to look like this:

OnlyShowIn=GNOME;Unity;XFCE

To check that it worked, restart XFCE and inspect the output of netstat -antp
for an instance of vino server listening on port 5900.

For convenience rearrange the desktop options in /etc/xrdp/xrdp.ini so that the main desktop (console) is at the top. Make the username blank so that all you hve to type is the password.

[xrdp1]
name=console
lib=libvnc.so
username=
password=ask
ip=127.0.0.1
port=5900

Use Remmina for everyday RDP use in Xubuntu. It’s like the best of the Windows built-in client and RdpMan. You can save connection settings and you get the floating menu when you are connected.

Remmina’s awesome feature is thgat it automatically scales the desktop to fit your screen. Useful if your main desktop is on a widescreen TV!

The Windows client actually supports this too, but it’s hidden. Right click on top-left icon and choose “smart sizing” to fit the large screen into the smaller one.

Gotchas

Getting remote desktops (not shared) was enough of an acheivement, so I plaued about with those for a while.

Evnetually youĺl get this message if you keep not logging out properly.

xrdp_mm_process_login_response: login failed

http://linuxtoolkit.blogspot.sg/2013/03/xrdpmmprocessloginresponse-login-failed.html

I followed the advice of Linux Toolkits to delete old X sessions and restart the xrdp.

Still no joy.

Looked at -var-log-xrdp-sesman.log and saw that it still thought it had ran out of displays.

Linux Toolkits encountered this too

http://linuxtoolkit.blogspot.co.uk/2013/09/x-server-no-display-in-range-is.html

Instead of just upping MaxSessions to 100, I reset the X11DisplayOffset counter to 1 and restarted the server.

http://linuxtoolkit.blogspot.co.uk/2013/09/x-server-no-display-in-range-is.html

At some point something messed with the ownership of an .Xauthority file.

http://askubuntu.com/questions/350692/xubuntu-13-04-x-login-loop

I saw messages like this when I was trying to run “gksudo mousepad”:

“Failed to run usr/sbin/synaptic as user root
Unable to copy the user’s Xauthorization file.”.

http://ubuntuforums.org/showthread.php?t=898233

I thought it was just Xubuntu being weird about something.

But when I restarted the media center it prompted me for a password, even though I asked it not to.

And when I gave it the password it just asked me again, and again, and again.

CTRL + ALT + F2 got me to the emergency shell and I could log in there.

sudo chown sandport:sanport .Xauthority

So I learned a lot of useful stuff, and gained some appreciation for how well tested Windows is!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s