Ubuntu 22.04 remote deskop headless?

I just installed Ubuntu 22.04 LTS and was delighted to see that a remote desktop server is built in and supports MS RDP in addition to VNC. It has some quirks related to the password, which I found out about on this post:22.04 - Remote Desktop Sharing authentication password changes every reboot

I am hoping to have remote desktop available on boot, without logging in, or if it uses auto-login it keeps the password, so that I can run the system headless and RDP/VNC into it. It looks like gnome-remote-desktop runs as a user service, not a system service, so it's not active unless the user logs in. And it starts before the keyring is unlocked, so it creates a new password every time it starts. It seems like there are many ways to get around these issue, but I'm not sure what's the best route or even if any/all of these are possible:

  1. Continue using auto-login so that remote desktop can run as a user service but somehow fix it so that it keeps the same password (ideally without disabling keyring completely).

  2. 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.

  3. Is it possible to convert the gnome-remote-desktop user service to a system service? And if so, where would it store the password if not in the user keyring? Is this even an option at all?

  4. Something else?!

Would love any suggestions. Thanks.

3

2 Answers

I have tried this solution in a VM

  1. 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:

enter image description here

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

Install xrdp

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:

enter image description here

  1. Set Session to XOrg, the default.
  2. Use your remote Ubuntu Computer's username
  3. 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:

enter image description here

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

hope this helps

Quoting my answer from another question, this will ensure that only the VNC/RDP password is unencrypted, everything else works with the default login keyring

I found an insecure solution to the problem. The typical solution proposed on the internet for this is to set a blank password for the login keyring using the "Passwords and keys" app. This, however, is highly inscure as all the passwords on the device would be stored in plaintext.

What I decided to do instead was to create a new keyring in the "Passwords and keys" app with no password and set it as the default keyring. Then I proceeded to delete the VNC password from the login keyring. Then I rebooted the computer to ensure that the new keyring is the default one. After the reboot, I reentered the VNC password in the screen sharing settings. This would store the VNC password in the new insecure keyring. Then back to "Passwords and keys" app and set the login keyring to default again. Rebooted again and now the VNC password stayed saved and the default keyring was also back to the login keyring, ensuring all foture passwords saved on the device will be encrypted.

So in essence, I just reduced the insecurity of saving all the passwords in plaintext to storing just the VNC password in plaintext.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like