最新

meta‘s blog

2013-10-15 How to build virtual desktop infrastructure with xrdp & x11rdp on #FreeBSD

How to build virtual desktop infrastructure with xrdp & x11rdp on #FreeBSD

This article explains how to build virtual desktop infrastructure with xrdp & x11rdp on FreeBSD.

Basic explanation

This article is written for FreeBSD 9.2-RELEASE. It may work with other releases but I haven't confirmed yet.

$ prompt means you run following command as a normal user. # prompt means you run following command as super user. ${PREFIX} is usually /usr/local.

Here's the target versions.

FreeBSD
9.2-RELEASE
xrdp
xrdp-0.6.0_4,1 or xrdp-0.6.1,1
x11rdp
x11rdp-0.5.0.299

Step 1. Keep ports tree up to date

First of all, keep ports tree up to date using portsnap(8) or anything you prefer. Here's an example to update ports tree with portsnap(8).

# portsnap fetch update

Step 2. Install net/xrdp

Just install net/xrdp.

# make -C /usr/ports/net/xrdp install clean

Run following command instead of `make install` if you use portmaster.

# portmaster net/xrdp

Make sure all XVNC options are disabled because you use X11rdp instead of Xvnc now. Either is OK for JP106 option. If you don't need Japanese keyboard you can disable it.

Step 3. Obtain x11rdp from my redports repository and install

May 1 2014: Now x11-servers/x11rdp is available in official ports tree. X11rdp will be installed by default configuration. You can skip this step.

If you haven't installed subversion, install it first.

# make -C /usr/ports/devel/subversion
# portmaster devel/subversion

Then, run the following command in your home directory to obtain x11rdp port. If you asked to accept ssl certificate, accept it.

$ svn co https://svn.redports.org/meta/x11-servers/x11rdp/

After that, build x11rdp and install. This may take a while (30 minutes or so).

$ cd x11rdp
# make fetch
$ make
# make install

Step 4. Configure net/xrdp

May 1 2014: This patch is already included current xrdp ports. Skip to editing /etc/rc.conf.

By default setting, xrdp uses Xvnc to raise X session. Apply this patch to xrdp.ini in order to use X11rdp instead of Xvnc.

$ cd /tmp
$ fetch https://gist.github.com/metalefty/6983663/raw/9fc314a16ad35c149dc418beac10b5e4ca8bf4a2/patch-xrdp.ini
$ cd /usr/local/etc/xrdp
# patch < /tmp/patch-xrdp.ini

To enhance seurity, find the following line in ${PREFIX}/etc/xrdp.ini and replace low with high.

crypt_level=low

will be:

crypt_level=high

Add following two lines to /etc/rc.conf.

xrdp_enable="YES"
xrdp_sesman_enable="YES"

And then, launch xrdp daemons.

# service xrdp start

Step 5. Install desktop environment

For instance, I use xfce4 for desktop environment. Run the following command to install xfce4. This may take much longer than Step 3.

# make -C /usr/ports/x11-wm/xfce4 config-recursive install clean

or

# portmaster -d x11-wm/xfce4

You don't have to install gdm login manager.

Step 6. Configure startvm.sh

You may need to set your language in ${PREFIX}/etc/xrdp/startwm.sh. For example:

export LANG=ja_JP.UTF-8

or

export LANG=de_DE.UTF-8

or something. You can set other environment variables such as an input method.

Each user can override ${PREFIX}/etc/xrdp/startwm.sh by placing startwm.sh in her home directory.

Step 7. Finally connect to virtual desktop via RDP

Conect to virtual desktop with Microsoft Remote Desktop Client for Win/Mac, Remmina, or FreeRDP. Here's the sample screenshots on Mac.

Input IP address or hostname of xrdp server.

Enter your username and password.

You will be reach xfce4 desktop environment.

If you reconnect with client which have different resolutions, the X11 session would be automatically resized on reconnect.

Step 8. Enjoy your virtual desktop

Install Firefox, Libreoffice, and many other useful GUI software, enjoy!

Limitations

xrdp v0.6 cannot redirect sounds to client. All sound are played server side. Sound redirection is available with xrdp v0.7 via pulseaudio. However current portversion of net/xrdp-devel (0.7.0.20120918) is very experimental and sound redirection is not available yet. I'm working on porting latest xrdp v0.7 to FreeBSD. I will write another article to use latest xrdp v0.7 in a few weeks.

Any questions, please leave comments this article or email me meta_at_vmeta.jp.