Securing Local Display for Remote Connection
It is my understanding that it is not possible to protect your computer from local physical intrusion while using it remotely using the new "Remote Login" RDP method.
If your concern is someone may watch your screen locally and get sensitive information, or worse, takeover your computer locally while you are connected remotely, then install xrdp
and bypass the "new Remote login" RDP method.
The new (as of Ubuntu 22.04) GNOME Remote Desktop does not allow a remote connection if you are not logged in locally in the remote computer. On the other hand, xrdp
does not allow remote connection if you are logged in locally.
To install the xrdp
server, open a terminal and enter:
sudo apt install xrdp
This will install the full xrdp server app. It will allow you to remotely connect to your computer if and only if you are NOT logged in locally. When you login remotely using RDP (xrdp) your local monitor will not turn on and show potential observers and intruders what you are doing.
See Ubuntu 22.04 remote desktop headless? for more details.
Remote Connection with Local login (Original Answer)
GNOME Shell Extension: Allow locked Remote Desktop
The solution below is for problem with screen lock and the new GNOME Remote Desktop in Ubuntu 22.04 that allows RDP (and legacy VNC) protocol for remote desktop sharing. If someone is physically near your your computer they will see your activities on the connected monitor and thus be able to collect sensitive information.
You will need a GNOME Shell extension to solve this problem.
First, install install gnome-shell-extension-manager
with this command:
sudo apt install gnome-shell-extension-manager
The open the newly installed app called Extension in the GUI. Within this app, search for and install the Allow locked Remote Desktop GNOME Shell extension.
Now you will be able to remotely connect to this computer even when the screen is locked. You will still need to be logged in locally first.
Hope this helps