Remote control the latest ubuntu22 server (turn off the monitor)

#virtualdisplay;#offdisplay;#nodisplay;remotemaintenance#operation and maintenance personnel

Preface

The VNC remote desktop that comes with Ubuntu is also very easy to use, but its logical basis is: the user of the controlled machine is using the host, so the monitor is turned on and the user logs in are the two basic conditions for using native VNC; this results in the following two situations , that is, when the monitor connected to Ubuntu is turned off, that is, no monitor is connected through VNC, or when the user locks the screen, if VNC logs in, remote control software including logically similar Teamviewer and Anydesk cannot access the Ubuntu system normally.

The latest Ubuntu22 has strengthened this point. The problems left over from previous versions of Ubuntu, including bugs or cracks, have been blocked in this version. As a result, many people spend a lot of time and do useless work.

2023 Solutions

Enable native VNC and use XRDP solution!

Disable native desktop sharing

You don’t need to do this step because it’s not very useful. I found after the next installation that disabling remote desktop had no effect. After xrdp restarts, the remote desktop settings are restored.

One word of caution: Make sure Enable legacy VNC protocol is unchecked .

Note: This settings page displays randomly generated passwords. ignore it. xrdp Use your login password when using a client such as Remmina in Ubuntu or the default RDP application in Windows

Install xrdp

The above settings didn't work in my fresh install of Ubuntu 22.04 until I installed xrdp. You must have physical access to the headless machine or use ssh for this step.

Ctrl opens a terminal via ++ and enter Alt:T

sudo apt install xrdp

You will be prompted for your password. The cursor does not move when you enter your password. this is normal.

If ufw is enabled, port 3389 must be opened using the following command:

sudo ufw allows 3389.

Verify that the xrdp server is up and running using the following command:

sudo systemctl status xrdp

Remember to log out

Logging out (locally) is the most important part. If you log in by physically accessing your computer and connecting a keyboard, mouse, monitor, etc., xrdp won't work until you log out.

Notes on xrdp local and remote login

Do not use automatic login to the desktop when the computer starts!

Unlike RDP in Windows, xrdp only works if you are not logged in locally to the remote machine. This means that you actually go to the remote computer and log in, then leave the computer without logging out, will not work. xrdp

Likewise, when logging in remotely via xrdp you can disconnect without logging out and the session will continue. However, in this case you will not be able to log in locally until you log out remotely.

This isn't a problem with headless machines because you are never logged in locally.

Two points about XRDP/RDP clients

1. Sessions, Users and Passwords

When you try to access a remote computer using (X)/RDP, you may see this dialog box on the RDP/XRDP client:

  1. Set the session to the default XOrg.

  1. Use the username of your remote Ubuntu machine

  1. Use the login password of the user on the remote Ubuntu computer. Do not use randomly generated passwords when setting up (x)RDP clients.

If you use Remmina and choose to store your username and password in the connection configuration, you will not see this dialog box.

2. The desktop may look different

When I use Remmina xrdp to get into Ubuntu22.04 in a VM, I don't get the default Ubuntu desktop. Instead, I get a Gnome 42 desktop that looks like this:

There may be some way to change it back to the Ubuntu desktop, but I didn't explore it.

reference:

https://askubuntu.com/questions/1407444/ubuntu-22-04-remote-desktop-headless/1409120#1409120

Guess you like

Origin blog.csdn.net/clayluo/article/details/128665467