Xrdp

xrdp is a program for providing connections to an X display using Microsoft's Remote Desktop protocol/client. It is useful for getting a remote GUI to a Linux server from a Windows machine without having to install an X server on the Windows machine, or on a machine that can't run an X server but can use a Remote Desktop client, such as a Windows Mobile phone.

Installation
First, Install Gentoo's bleeding-edge Overlay.

Then edit the /etc/make.conf file and set PORTDIR_OVERLAY variable as follows:

Second, make sure the USE flag is enabled for, and remerge it if necessary. Next, add to :

Finally emerge xrdp from bleeding-edge portage overlay:

Configuration
First of all you need to create a remote X session. It can be a real or virtual X display. It is possible to do this with a vnc server (Xvnc or Xvfb) or a X11rdp server. After creating the X session, Xrdp helps you to find this session and forward it from the local machine.

Configuring VNC
It is possible to use TigerVNC, TightVNC, vnc4server, X11VNC or ... to create a VNC session. TigerVNC, TightVNC and vnc4server are able to generate a virtual X session, but X11VNC works with a pre-existing X session. As a result, if you have a server that does not have a monitor (headless), it would be wiser choice to create a virtual X session, but if you need to work with opengl or a pre-existing X session X11VNC is recommended. All the VNC servers are configured with a script named "vncserver". Running this script for the fist time, asks you for a password (that is saved in a file named "passwd") and creates an appropriate "xstartup" script for you. These two files are stored in ~/.vnc in the users home. xstartup script determines which desktop should be started after connecting to the VNC. Other than doing the primary setup, vncserver helps you to create temporary virtual X sessions. For example, the following command helps you to create a virtual vnc server:

or if you need more options:

A program named Xvnc listens for connections to these sessions on port 5900 plus the number of the display (e.x. 5900, 5901 ...). In this example :2 is the number of the display and therefore it is associated to port 5902. In this example, we assume that this machine has two local monitors and they are in use. For example, assume that the xdm init script is started on the machine. Therefore, X displays :0 and :1 are already in use, and if we need a new virtual X display, we should use X display :2. It should be obvious that if xdm was not started on the machine, virtual VNC display could be configured to use X displays :0 or :1. VNC by convention also numbers its displays corresponding to the X displays they run on, so VNC display :2 will use X display :2.

"/etc/init.d/tigervnc" init scrip of TigerVNC or "/etc/init.d/vnc" init scrip of TightVNC help us to initiate a VNC session on boot. Configuration of these scripts are located in /etc/conf.d/tigervnc or /etc/conf.d/vnc. Configuration of X11VNC and TightVNC are described separately elsewhere. Here we cover TigerVNC because of its superior quality.

It is possible to configure TigerVNC by editing. This file must at least define the DISPLAY variable. For example:

Replace "username" with the user the VNC client will be connecting as.

Again, VNC listens on port 5900 plus the number of the display, so if the machine being configured already has two X displays running and VNC starts at display :2, the VNC server will listen on port 5902. Since the standard VNC port is 5900 and not all VNC clients can be configured to connect to a different port, explicitly telling the VNC client to listen on port 5900 might be a good idea. Do this by adding the following line to :

for more information about configuration options (VNC_OPTS) see vncserver or Xvnc manuals.

For example you can fix resolution and colour depth of the VNC client to constant values. "1280x800 24bit" in this example:

To pass arguments to the Xvnc command add parameter statements into:

Create VNC passwords for your user. Log in as the user ("username" in this example) and type command:

Now (re-)start VNC:

Configuring the VNC user(s)
Whatever user was used in the DISPLAY line described above will need to configure a VNC password by running at a terminal. They may also want to edit to start a window manager they like when they log in (the default is twm).

To use with XFCE4 VM
Edit. This will work with KDE or GNOME as well.

test your vnc server
The vnc server that we configured is accessible with a normal vnc server like remmina on linux or TigerVNC viewer of windows. You can test your vnc server with these clients before configuring the xrdp.

Configuring xrdp
xrdp has several configuration files, described in the xrdp(8) man page. Gentoo provides default configuration files, but as of xrdp 0.3.1 they are not adequate as a default install. In, the first section after "[globals]", which would be shown as default option of xrdp login page, needs to look like this:

Now (re-)start xrdp:

Note: It is possible to compile xrdp with extra configuration options to enable sound, jpeg and fuse support:

Connecting
Use a Remote Desktop client to connect to the server running xrdp. The username is the user defined in the DISPLAY variable in, and the password is that user's VNC password.

Sample rdesktop client connection command. rdesktop serverip -u username -p password -g 1024x768 -a 16 -x m

Clients known to work

 * Windows 7 Remote Desktop
 * Windows 8 Remote Desktop (not the WinRT one)
 * Remote Desktop Mobile for Windows Mobile
 * If having problems with Windows 5 or 6 Mobile clients be sure to get the latest git checkout, otherwise keyboard events might not be sent.
 * Window CE 5 built in client
 * rdesktop and Remmina for Linux

Note: My experiments show that the TigerVNC viewer of windows has a better performance than the Remote Desktop clients of windows that using the xrdp to translate vnc to rdp.

Clients known to not work

 * Remote Desktop Connection for Mac OS X: connects fine but can't type.
 * Fixed in RDC for Mac OS X 2.1

Administrating
Nice command to see who is logged into a xrdp vnc session ps -ef | grep Xvnc You can then find out what display is being used and manually vnc into that display with vncclient serverip:dispaynumber