Rotten mud: Learning ubuntu Remote Desktop (2): Remote Desktop session management, rotten mud ubuntu

Source: Internet
Author: User

Rotten mud: Learning ubuntu Remote Desktop (2): Remote Desktop session management, rotten mud ubuntu

This document consistsXiuyi Lin FengProviding friendship sponsorship, first launchedThe world

In the previous article, we explained how to install remote desktop and Its configuration for ubuntu. In this article, we will explain the problems related to ubuntu remote desktop session.

I. Problem Description

This problem often occurs when we use ubuntu Remote Desktop. When connecting to the Remote Desktop, I open session A, and I handle some work in session. The remote desktop session is closed because you accidentally shut down the remote desktop or close the remote desktop session after work is completed today. When we connect to the Remote Desktop, we find that ubuntu will provide A new remote desktop session B, instead of the session A we just connected to, or the session A we connected yesterday.

We often encounter this problem in our actual work.

So how can we solve this problem? Or in another way, how do we connect to the last remote desktop session?

Note: All ubuntu Remote Desktop in this article is based on the XRDP protocol.

Ii. Principles of ubuntu Remote Desktop

To solve the above problems, we need to understand the relationship between ubuntu Remote Desktop and vncserver Based on xrdp protocol.

In fact, we have mentioned the principles of ubuntu Remote Desktop in the previous article "mud: Learning ubuntu Remote Desktop (1): Configuring Remote Desktop, XRDP-based Remote Desktop Connection requires vncserver support.

Why is vncserver required?It is because when we connect to the ubuntu Remote Desktop through port 3389, xrdp will forward all data through port 3389 To The vncserver port, and vncserver only listens to the address 127.0.0.1, therefore, the vncserver port is not open to the outside world.

In addition, the vncserver assigns a system port for each remote desktop session. Note that this port is very important.

If we want to connect to the last remote desktop session A, we only need to connect to the vncserver port where session A is located.

How can we connect to and view the vncserver port? Therefore, we need to modify the related configurations of xrdp.

Why is this principle explained? It is because we understand this principle, so we can easily solve the problem of ubuntu remote desktop session, but also can easily understand, we modify the xrdp configuration file.

Iii. XRDP configuration file details

There are two XRDP configuration files: xrdp. ini and sesman. ini in the/etc/xrdp directory.

The key part of the xrdp. ini configuration file is globals. The specific content is as follows:

[Globals]

Bitmap_cache = yes bitmap cache

Bitmap_compression = yes bitmap Compression

Port = 3389 xrdp listening port (important)

Crypt_level = low encryption level (40 bits for low, 128 bits for high, and 40 bits for medium)

Channel_code = 1

Max_bpp = 24 XRDP Max 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, pay attention to the max_bpp parameter, which defines the maximum number of connections of XRDP.

To solve this problem, we only need to modify the port parameter in sesman-Xvnc mode. The modified prot parameter is as follows:

Cat/etc/xrdp. ini

The sesman. ini configuration file contains the following content:

[Globals]

ListenAddress = 127.0.0.1 listening IP address (default)

ListenPort = 3350 listener port (default)

EnableUserWindowManager = 1 enabled, allowing you to customize your own startup script

UserWindowManager = startwm. sh

DefaultWindowManager = startwm. sh

[Security]

AllowRootLogin = 1 allow root login

MaxLoginRetry = 4 maximum number of retries

TerminalServerUsers = user group that tSUSErs allows to connect to (if not, all users are allowed to connect by default)

TerminalServerAdmins = Super Users Allowed to connect to tsadmins (if not, all users are allowed to connect by default)

[Sessions]

MaxSessions = 10 maximum number of sessions per user

KillDisconnected = 0 whether to immediately close the disconnected connection (if it is 1, the connection will be automatically canceled after the disconnection)

IdleTimeLimit = 0 Idle session time limit (0 is unlimited)

DisconnectedTimeLimit = 0 the survival time of the disconnection (0 is unlimited)

[Logging]

LogFile =./sesman. log file

LogLevel = DEBUG logging level (level: core, error, warn, info, debug)

EnableSyslog = 0 whether to enable log

SyslogLevel = DEBUG system log record level

4. Connect to the Remote Desktop

Now we can connect to ubuntu through remote desktop, as shown below:

Note: The port number marked in the figure

After the Remote Desktop Connection enters, open the terminal and create a file test, as shown below:

After the test is created, close the Remote Desktop Connection.

Note: I did not close the page for creating the file for the following demonstration.

Log on to ubuntu through ssh and check the port used by the vncserver as follows:

Netstat-tunlp

Ps-ef | grep 1673

Through this, we can know that the current session, vncserver uses port 5912.

Modify the configuration file xrdp. ini of xrdp as follows:

Sudo vi/etc/xrdp. ini

After the preceding modification, restart xrdp as follows:

Sudo/etc/init. d/xrdp restart

After the restart, connect to the Remote Desktop again, as shown below:

Note: We enter port 5912, that is, the port used by the Remote Desktop session vncserver above.

After the Remote Desktop is entered, it is as follows:

We can clearly see that we did connect to the Remote Desktop interface closed last time.

PS: if you do not know the port of each connection, you can view the user's xrdp log on. The procedure is as follows:

Sudo cat/var/log/xrdp-sesman.log

You can use the xrdp log to view the user-initiated xrdp pid.

Then, view the started xrdp process based on the pid, as shown below:

Ps-ef | grep 1693

The result shows that the xrdp process uses port 5912.

To confirm the port number more clearly, run the netstat command as follows:

Netstat-tunlp

Through, we can clearly see that the pid is 1693 xrdp, using port 5912.

All problems related to ubuntu remote desktop sessions have ended.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.