83

I have been trying to set up a RDP terminal server on precise using xrdp and have been having significant trouble getting a working configuration. When a user logs on, I need it to connect to that users existing session if it exists, otherwise starting a new session, and any started session must start LXDE. What changes to the default configuration do I need to make in order for this to work?

Jorge Castro
  • 73,717
nloewen
  • 931
  • 1
  • 7
  • 6

12 Answers12

58

I had this same problem, and I just found an easy solution. I originally just installed xrdp using the standard proceedure:

apt-get install xrdp

After that, its all about your xrdp.ini file, which is located here:

/etc/xrdp/xrdp.ini

To open and edit the xrdp's configuration file use:

sudo nano /etc/xrdp/xrdp.ini

by default the first xrdp session handling script looks like this:

[xrdp1]
name=sesman-vnc
lib=libvnc.so
username=ask
password=ask
ip=127.0.0.1
port=-1

The important line is port=-1, this makes xrdp always look for a free port to connect. If you set a fixed port here, the xrdp will always go back and connect to the same session. I changed mine so it looks like this:

[xrdp1]
name=customsessionname
lib=libvnc.so
username=myusername
password=ask
ip=127.0.0.1
port=5912

Thats it, I think you could get away with just changing the port=-1 to port=5912. My xrdp always re-connects to existing session always using the same port.

29

I'd like to improve on an existing answer. The top voted answer was to edit the xrdp.ini file to change port to a fixed value in place of the -1 wildcard to find an open port.

I tried that, but got an error connecting the first time, so ended up switching back to the -1 value. Frustration quickly set in though with the issue remaining of not resuming so I looked at the ini file again.

What worked for me, and was really just something I was curious about was this:

Edit the /etc/xrdp/xrdp.ini

Under [xrdp1] where port=-1 I noticed user name and password were set to ASK. If you set port=ask you will be given the option at the login prompt with username and password to choose a port.

Rather than install additional packages I found the easiest fix to be to set the ask option, connect the FIRST session (if I don't have one running already) on port -1 at the login with username and password.
After disconnecting the session, to resume an existing session always log in on the default port: 5910 and you will resume your existing session until you restart the remote computer or end the session when logging off.

To summarize:

  • Edit the xrdp.ini file
  • set port = ask
  • connect from the remote machine, and at login if you have no existing session, specify port -1
  • to resume a session enter the default of 5910
n611x007
  • 565
4

Problem is that xrdp does not always connect to the same port. In case it didn't and you forgot the port number, you could login a ssh session and find out the number by

netstat -tulpn | grep vnc

and you will get something like the following

tcp        0      0 127.0.0.1:5911          0.0.0.0:*               LISTEN      5365/Xvnc

and then you know 5911 was the port you connected to.

YH Wu
  • 151
2

If you encountered the problem of "password failed", you might take a look at the two issues in GitHub

Reconnect to old vnc session - VNC password failed

VNC Password failed when picking existing session

In short, they mention that specifying port number no longer works in latest design.

wai
  • 21
2

on the log in screen with the xrdp box when you first connect to the remote desktop there should be a drop down box, from here choose "vnc-any" then input the ip address of the computer and the password but leave the port at what it is, this should help :)

Dewi Jones
  • 121
  • 5
1

1. Modifiy you xrdp.ini:

sudo vi /etc/xrdp/xrdp.ini

2.Change the port setting port=ask-1 in your connection rule:

[xrdp1]
name=sesman-Xvnc
lib=libvnc.so
username=ask
password=ask
ip=127.0.0.1
port=ask-1

3.Restart your xrdp Service

sudo service xrdp restart

You should see the following picture when you login by remote desktop. enter image description here

1. At first login you can see this port number. Example:5912 : enter image description here

If you forget this port number, you can using the following command to check:

netstat -peant | grep 59 | grep Xvnc

2. You can re-connect the last session by your port number. enter image description here


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

W. Dan
  • 121
1

As of Linux Mint/Ubuntu 20, to solve general problems with xrdp I've always found it useful to avoid installing the pre-compiled packages, and building them from source instead.

Not all the features are enabled in the stock packages: for instance the sound and the clipboard channels have to be explicitly enabled with configure switches, plus the keyboard mapping files are often outdated and some keys like the curly brackets didn't work for me. Most of the problems magically disappeared when I installed the custom compiled version.

You might want to compile and install xrdp and xorgxrdp (the xrdp session manager similar to x11rdp), following the instructions here and here, then tweak the /etc/xrdp.ini and /etc/xrdp/sesman.ini files, the latter used by Xorg(xrdp). I recommend disabling dynamic channels in the first one to lower the client and server CPU consumption.

For good measure, I use a compiled version of the client too (Remmina), just to make sure that both fit my machines like a glove.

0

Here's what I did. Make sure tigervnc-server is installed so we can use Xvnc. Launch a VNC session with the default configuration (I actually followed the Arch Linux setup guide for TigerVNC). Then configure your Xrdp to use that VNC session every time. Also set TigerVNC to startup on boot or something. This is the only VNC section in my xrdp.ini file:

[vnc-any]
name=vnc-any
lib=libvnc.so
ip=localhost
port=5901
username=na
password=YOURPASSWORD
#pamusername=asksame
#pampassword=asksame
#pamsessionmng=127.0.0.1
#delay_ms=2000
Nevar
  • 1
0

If using Windows Remote Desktop Client to connect to a Linux session, I've found that maintaining the same display configuration and color depth will reconnect a user to the same session. Those parameters can be adjusted by selecting "Show Options" at bottom left of the startup screen and then select the "Display" tab.

If you don't know what your display parameters were of your existing session, start a new session and then from a terminal window run ps axf | grep vnc. Your display parameters of your existing and new rdp sessions will show something like -geometry 1920x1080 -depth 16. Make note of these values, logout from your new session and then attempt another xrdp login using your discovered values.

0

for me, this works

in dir

/etc/rdp

in xrdp.ini add these two lines

session_timeout=0
reconnect_sharing=true

in startwm.sh

I backup the old file by making it copy and added this code

#!/bin/sh
# xrdp X session start script (c) 2015, 2017, 2021 mirabilos
# published under The MirOS Licence

Rely on /etc/pam.d/xrdp-sesman using pam_env to load both

/etc/environment and /etc/default/locale to initialise the

locale and the user environment properly.

if test -r /etc/profile; then . /etc/profile fi

if test -r ~/.profile; then . ~/.profile fi

Check if there is an existing session

if test -r /var/run/xrdp/sessions; then echo "Reusing existing XRDP session..." exec /etc/X11/Xsession else # If no session exists, start a new one echo "Starting new XRDP session..." test -x /etc/X11/Xsession && exec /etc/X11/Xsession exec /bin/sh /etc/X11/Xsession fi

0

I ran into this problem on a Debian machine. Used X11RDP-o-Matic to build xrdp 0.7 packages. Prior to upgrading to systemd, xrdp session reconnect worked fine.

Looking at the process tree I could see that the sessions were no longer children of xrdp-sesman. Turned out to be a permissions issue when using systemd. Google found a patch that fixes the problem.

How do you identify a working reconnect? Run ps axf and look at the process tree for xrdp-sesman. X11rdp, xrdp-chansrv, xrdp-sessvc should all be running as a child. If they are not, xrdp-sesman will not know how to reconnect to the session.

Here's what it looks like when working:

good xrdp session process

h0tw1r3
  • 121
-1

This UbuntuForum thread looks useful - I havent tested this myself - however I've copied the solution given here to complete this answer.

RealVNC setup

1. Uninstallation of the default Ubuntu VNC server (Vino):

Go to: System --> Administration --> Synaptic Package Manager Search for the "Vino" package, Mark For Removal, Apply.

2. Installation of TightVNC and XRDP:

While you are using Synaptic Package Manager, seacrh for "tightvnc" package (be careful, not "xtightvnc") and Mark For Installation. Likewise, search for the "xrdp" package and Mark also For Installation. Apply. PS: if you want, you may discard any other "vnc" package that you don't need!

3. Configuration of XRDP (Optional)

Open a terminal and type the three following commands:

 cd /etc/xrdp
 cp xrdp.ini xrdp.ini.bak 
 sudo gedit /etc/xrdp/xrdp.ini

Remove Xrdp2-Xrdp6 sections, leave only the Xrdp1 section. Your xrdp.ini should look like this:

[globals]
bitmap_cache=yes
bitmap_compression=yes
port=3389
crypt_level=low
channel_code=1

[xrdp1]
name=RDP_To_TightVNC
lib=libvnc.so
username=ask
password=ask
ip=127.0.0.1
port=-1

4. Connecting

Restart the system and you are ready to connect!

To connect from another Ubuntu machine, use: Applications --> Internet --> Terminal Server Client, type the IP of your Ubuntu VNC machine, use RDPv5 or RDP, click Connect!

To connect from a Windows-based machine, use: Start --> Run --> mstsc, type the IP of your Ubuntu VNC machine, click Connect.

When connected, use your Ubuntu user account credentials (u/n and p/w) and remotely login to your desktop.

fossfreedom
  • 174,526
Rahul Virpara
  • 11,860