this article starting at 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
650) this.width=650; "title=" clip_image001 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image001" src= "Http://s3.51cto.com/wyfs02/M01/6E/AF/wKioL1WC0DmipgLuAAE_wufbQGA638.jpg" Width= "301" height= "431"/>
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:
650) this.width=650; "title=" clip_image002 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image002" src= "Http://s3.51cto.com/wyfs02/M02/6E/AF/wKioL1WC0DqQTWxkAAGpzalVJk8111.jpg" Width= "409" height= "413"/>
Note: The port number marked in the figure
After the Remote Desktop Connection enters, open the terminal to create a file test, as follows:
650) this.width=650; "title=" clip_image003 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image003" src= "Http://s3.51cto.com/wyfs02/M00/6E/AF/wKioL1WC0DyRf7MKAAIMe6081hs446.jpg" Width= "730" height= "510"/>
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
650) this.width=650; "title=" clip_image004 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image004" src= "Http://s3.51cto.com/wyfs02/M01/6E/AF/wKioL1WC0D3wZwp0AANzDT2cNsY289.jpg" Width= "732" height= "349"/>
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
650) this.width=650; "title=" clip_image005 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image005" src= "Http://s3.51cto.com/wyfs02/M02/6E/AF/wKioL1WC0D3zEV9LAAFybvlH338194.jpg" Width= "327" height= "446"/>
After the above modification, we want to restart XRDP, as follows:
SUDO/ETC/INIT.D/XRDP restart
650) this.width=650; "title=" clip_image006 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image006" src= "Http://s3.51cto.com/wyfs02/M00/6E/AF/wKioL1WC0D6gLJxGAAC2xd2FwRM292.jpg" Width= "379" height= "/>"
After the reboot is complete, we connect to the Remote Desktop again, as follows:
650) this.width=650; "title=" clip_image007 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image007" src= "Http://s3.51cto.com/wyfs02/M02/6E/AF/wKioL1WC0D-DGMP9AAGABGNkH6E424.jpg" Width= "501" height= "427"/>
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:
650) this.width=650; "title=" clip_image008 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image008" src= "Http://s3.51cto.com/wyfs02/M01/6E/B3/wKiom1WCzo7TobDRAAFordpgyJw319.jpg" Width= "608" height= "411"/>
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
650) this.width=650; "title=" clip_image009 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image009" src= "Http://s3.51cto.com/wyfs02/M02/6E/B3/wKiom1WCzo_xa4KlAAUhXgSpn7g683.jpg" Width= "649" height= "439"/>
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
650) this.width=650; "title=" clip_image010 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image010" src= "Http://s3.51cto.com/wyfs02/M00/6E/B3/wKiom1WCzpDS-LnWAAEh-n2jHh4741.jpg" Width= "816" height= "/>"
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
650) this.width=650; "title=" clip_image011 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;padding-right:0px;border-top-width:0px; "border=" 0 "alt = "clip_image011" src= "http://s3.51cto.com/wyfs02/M01/6E/B3/wKiom1WCzpKRr7lqAAH-HN-k76o945.jpg" width= "638" Height = "231"/>
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.
This article is from the "Slime Row World" blog, please be sure to keep this source http://ilanni.blog.51cto.com/526870/1663351
Slime: Learning Ubuntu Remote Desktop (ii): Remote Desktop session Management