This article consists of Su Yi Lin Feng provide sponsorship, starting in Slime Line the world
In the previous article, we explained how to install Remote Desktop for Ubuntu and its configuration, and we'll cover the issue of Ubuntu Remote Desktop session in this article.
First, the problem description
This is a common problem when we use Ubuntu Remote Desktop. When I was connecting to Remote Desktop, I opened session a, and I was working on some things under session a. Shut down the Remote Desktop session because you accidentally shut it down, or you are finished working today. When you connect to Remote Desktop again, it turns out that Ubuntu will give you a new Remote Desktop session B instead of the session a that we just connected to, or the session a that was connected yesterday.
The above problem, we are often encountered in the actual work.
So how do we solve this problem? Or in other words, how do we connect to the last Remote Desktop session a?
Note: The Ubuntu Remote Desktop in this article is all based on the XRDP protocol.
Second, the principle of Ubuntu Remote Desktop
To solve these problems, we need to understand the relationship between Ubuntu Remote Desktop and vncserver based on the XRDP protocol.
in fact, on the principle of Ubuntu Remote Desktop, we in the previous article " Slime: Learning Ubuntu Remote Desktop (i): Configuring Remote Desktop has already mentioned that Remote Desktop Connection based on XRDP mode requires Vncserver support .
Why do we need Vncserver's support? Because when we connect to the Ubuntu Remote Desktop over port 3389, XRDP will forward all the 3389 port data to the Vncserver port. At the same time Vncserver only listen to 127.0.0.1 this address, so Vncserver port is not open to the outside.
In addition, Vncserver also assigns a system port to each Remote Desktop session, noting that this port is important.
If we are going to connect to the last Remote Desktop session A, we only need to connect to the Vncserver port where session a is located.
So how can we connect and view this vncserver port? This requires us to modify the configuration of the XRDP.
Why are you explaining this principle? Because only we understand this principle, then we can easily solve the problem of Ubuntu Remote Desktop session, but also can easily understand, our XRDP configuration file related changes.
Three, XRDP configuration file detailed
There are two XRDP configuration files, respectively, Xrdp.ini and Sesman.ini files in the/ETC/XRDP directory.
Xrdp.ini configuration file, the key part in Globals, the specific content is as follows:
[Globals]
Bitmap_cache=yes Bitmap Caching
Bitmap_compression=yes Bitmap Compression
port=3389 XRDP Listening ports (important)
Crypt_level=low encryption (Low is 40 bit, high is 128 bit, medium is double 40 bit)
Channel_code=1
max_bpp=24 XRDP Maximum number of connections
[XRDP1]
Name=sesman-xvnc XRDP Connection mode
Lib=libvnc.so
Username=ask
Password=ask
ip=127.0.0.1
Port=-1
Note: In the Xrdp.ini configuration file, you need to be aware of the MAX_BPP parameter, which defines the maximum number of connections xrdp.
to solve the problem in this article, we only need to modify the port parameter in the SESMAN-XVNC mode. the modified prot parameter is as follows:
Cat/etc/xrdp/xrdp.ini
Sesman.ini configuration file with the following contents:
[Globals]
listenaddress=127.0.0.1 Listening IP address (default)
LISTENPORT=3350 listening port (default)
Enableuserwindowmanager=1 1 is turned on, allowing users to customize their own startup scripts
userwindowmanager=startwm.sh
defaultwindowmanager=startwm.sh
[Security]
Allowrootlogin=1 Allow root Login
maxloginretry=4 Maximum Retry count
Terminalserverusers=tsusers user groups allowed to connect (by default all users are allowed to connect if not present)
Terminalserveradmins=tsadmins Allow connected Super User (default all users allow connection if not present)
[Sessions]
maxsessions=10 maximum number of sessions per user
Killdisconnected=0 If the disconnected connection is immediately closed (if 1, it will be automatically logged off after the connection is disconnected)
Idletimelimit=0 Idle session time limit (0 for No limit)
Disconnectedtimelimit=0 time-to-live disconnection (0 No limit)
[Logging]
Logfile=./sesman.log Login log File
Loglevel=debug logging Level (level, core,error,warn,info,debug)
Enablesyslog=0 whether to turn on the log
Sysloglevel=debug System Logging Level
Iv. Connecting to Remote Desktops
Now let's connect to Ubuntu via Remote Desktop, as follows:
Note: The port number marked in the figure
After the Remote Desktop Connection enters, open the terminal to create a file test, as follows:
After the test is created, then close the Remote Desktop Connection.
Note: To create the file interface for the following demo effect, I did not close it.
At this point, we then login to Ubuntu via SSH to see the port used by Vncserver at this time, as follows:
Netstat–tunlp
Ps-ef |grep 1673
Through, we can know the current session, Vncserver using 5912 of this port.
Now let's modify the next xrdp configuration file Xrdp.ini, as follows:
sudo vi/etc/xrdp/xrdp.ini
After the above modification, we want to restart XRDP, as follows:
SUDO/ETC/INIT.D/XRDP restart
After the reboot is complete, we connect to the Remote Desktop again, as follows:
Note: The port in the port, we fill in 5912 this port, that is, the top of the Remote Desktop session Vncserver used by the ports.
When the remote Desktop goes in, the following:
By that we can clearly see that we are indeed connected to the Remote Desktop interface that was last closed.
PS: If you do not know the port of each connection, we can also view the user's XRDP log on the view. Specific steps, as follows:
sudo cat/var/log/xrdp-sesman.log
View the PID of the user starting XRDP through the XRDP log.
Then according to the PID, see the XRDP process started, as follows:
Ps-ef |grep 1693
By and by, it is basic to see that this XRDP process is using port 5912.
For a clearer confirmation of the port number, use the netstat command, as follows:
Netstat-tunlp
Through, it can be obvious that the PID is 1693 XRDP, using the 5912 port.
The problem with this Ubuntu Remote Desktop session is all over.
Slime: Learning Ubuntu Remote Desktop (ii): Remote Desktop session Management