«前の日記(2013-09-20) 最新 次の日記(2013-10-16)» 編集

meta's blog - The Power To Serve

筆者について

FreeBSDを通じてOSSにささかな貢献を。

OSS活動をご支援いただける方を募集しています


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.

install_net_xrdp.png

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.

rdc_for_mac.png

Enter your username and password.

xrdp_login_dialog.png

You will be reach xfce4 desktop environment.

small_xfce_desktop.png

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

medium_xfce_desktop.png

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.

本日のツッコミ(全16件) [ツッコミを入れる]
Σ Cheech (2013-11-24 09:32)

Greeet ! You are help me ! It's very good for me !

Σ meta (2013-11-25 09:32)

I'm glad to hear that.

Σ Paul Coucher (2014-03-26 01:29)

Yay \o/ RDP & native RDP at that! Compiles cleanly from the port now & only required a reverse patch & re-patch of the ini to switch to native.

Σ Petz (2014-05-01 15:13)

Great article. I got it working with the xrdp-devel-0.7.0.b20130912_1 on FreeBSD 10. However only with the Xvnc backend X11rdp give a error after authenticating.

Σ Petz (2014-05-01 16:14)

Look like it doesn't like the '-uds' option which was param5 in /usr/local/etc/xrdp/sesman.ini<br><br>I commented it out and restarted the service. But still not working. Not sure why now.<br><br>[X11rdp]<br>param1=-bs<br>param2=-ac<br>param3=-nolisten<br>param4=tcp<br>#param5=-uds<br><br><br>Maybe this is why? I don't quite understand that error though.<br><br>root@ip-172-31-14-71:/var/log # X11rdp :10 -geometry 1024x768 -depth 24 -bs -ac -nolisten tcp<br><br>X11rdp, an X server for xrdp<br>Version 0.5.0<br>Copyright (C) 2005-2008 Jay Sorg<br>See http://xrdp.sf.net for information on xrdp.<br>Underlying X server release 70100000, The X.Org Foundation<br>Xorg Release 7.1<br>Screen width 1024 height 768 depth 24 bpp 32<br>dpix 100 dpiy 100<br>buffer size 3145728<br><br>Fatal server error:<br>Couldn't add screen

Σ meta (2014-05-01 22:05)

The problem is you're using xrdp-devel. xrdp-devel-0.7.0.b20130912_1 is NOT compatible with x11rdp-0.5.0.299. <br>Did you try xrdp-0.6.1_3,1 with x11rdp-0.5.0.299? This combination works but other combinations don't.<br><br>If you want to use xrdp-devel-0.7.0, try x11rdp-devel on my redports repo but not well-tested.<br>https://svn.redports.org/meta/x11-servers/x11rdp-devel/<br><br>Please use the versions described on the top of this article. It will work.

Σ TK (2015-01-24 08:51)

Thank you for the inspiration, this was really what I was looking for. I am now enjoying mate-session straight from my server.

Σ Firewall (2015-03-02 22:31)

Is there no need to configure firewall to allow port 3389 ? I am using freebsd 10.1 and not able to access the desk top remotely. I am using MATE. I am using xrdp successfully on fedora but not on freeBSD. Could you please help? I am able to login to sesman-x11rdp but the session closes after few seconds. It says login Ok, but stops there.

Σ mahendra (2015-03-02 22:42)

Is there no need to configure firewall to allow port 3389 ? I am using freebsd 10.1 and not able to access the desk top remotely. I am using MATE. I am using xrdp successfully on fedora but not on freeBSD. Could you please help? I am able to login to sesman-x11rdp but the session closes after few seconds. It says login Ok, but stops there.<br><br>As I am using MATE, what should be the value in SESSIONS in file startwm.sh ? It now does not have anything to indicate MATE<br><br>It has:<br>SESSIONS="gnome-session blackbox fluxbox startxfce4 startkde xterm"

Σ meta (2015-03-03 11:30)

You need to pass port 3389, a matter of cource. If you're using MATE, edit SESSIONS to fit your desktop.<br>I'm not sure what exactly you should set SESSIONS because I don't use MATE but probably mate-session or something like that.

Σ floh!blogs_floh@deranfangvomen.de (2015-06-23 22:36)

Hi,<br><br>thank you, yours is the only good howto for rdp and freebsd!

Σ meta (2015-06-24 11:16)

Glad to hear that.<br><br>The latest stable version of xrdp which available on FreeBSD is still 0.6.1.<br>But hat version is now considered to be old. I'm planning to describe how to use the new version of xrdp and x11rdp, with TLS support.

Σ cj (2015-12-07 11:42)

thanks for this and everything else you contribute!!!!

Σ JB (2017-05-26 23:48)

Great article, thanks much! You may want to update it as x11rdp is now the default back-end, so no patches are needed and the process is much simpler.

Σ Jone (2017-09-05 23:17)

I follow above step. But I log in every time successfully that show connected ok. Then close the window itself. Why? I missed something? Please help me. I have installed and tried several times. I am confusing.

Σ Jone (2017-09-06 22:55)

Sorry! I have solved it. Because I install in vmware workstation. I haven't install vmware tools. Thanks.