How do I set up xrdp session that reuses an existing session?
Solution 1:
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.
Solution 2:
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
Solution 3:
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.