I have tried this solution in a VM
- Disable the built-in remote desktop feature and install some other RDP/VNC server and manually configure it, but would that conflict with
the built-in one? Not sure.
The solution I propose here is to not to use the native desktop sharing and use
xrdp server instead.
Disable the native desktop sharing (or not)
I found disabling Remote Desktop did not have any effect after I installed
xrdp in the next step. After a reboot, the Remote Desktop setting reverts to look like this:
Make sure the Enable Legacy VNC Protocol is not checked.
Note: This settings page shows a randomly generated password. Ignore it. Use your login password when you use an
xrdp client like Remmina in Ubuntu or Window's default RDP app
The setting above did not work in my fresh install of Ubuntu 22.04 until I installed
xrdp. You have to either physically access the headless computer or use
ssh for this step.
Open a terminal by Ctrl+Alt+T and enter:
sudo apt install xrdp
You will be prompted to enter your password. As you enter your password the cursor will not move. This is normal.
If you have
ufw enabled you will have to open the port 3389 with this command:
sudo ufw allow 3389.
Verify that the
xrdp server is up and running with this command:
sudo systemctl status xrdp
Remember to logout
Logging out (locally) is the most important part. If you login by physically going to the computer and connecting keyboard, mouse, monitor etc. then
xrdp won't work until you logout.
A Note about
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 to the remote computer locally. This means you physically go to the remote computer and login to it, and then leave the computer without logging out,
xrdp will not work.
Similarly, while remotely logged in via
xrdp you may disconnect without logging out and the session will continue. However, in this case, you won't be able to login locally until you log out remotely.
This is not a problem for a headless computer as you never login locally.
Two points for the XRDP/RDP Client
1. Session, User and Password
When you try to access the remote computer using (X)/RDP, you may see this dialog box on your RDP/XRDP client:
- Set Session to XOrg, the default.
- Use your remote Ubuntu Computer's username
- Use the remote Ubuntu computer user's login password. Do not use the randomly generated password when you set up the (x)RDP client.
You won't see this dialog if you use Remmina and choose to store your username and password with the connection configuration.
2. Desktop may look different
When I used Remmina to xrdp into the Ubuntu22.04 in the VM, I didn't get the default Ubuntu desktop. Instead I got the 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 that.
hope this helps