2022年6月21日 星期二

Configure chrome remote desktop in Ubuntu 20.04 (Updated June 2025)

Problems

Chrome remote desktop creates a new session for remote session, which is not suit my needs, like Windows's remote, I need to "resume" the current session of the original desktop.

Solutions

1. In the host Ubuntu machine, install chrome remote desktop, using the deb provided by Google making use of the command sudo dpkg -i chrome-remote-desktop_current_amd64.deb

2. In the host machine, install chrome remote desktop application, perform the remote host setup following the instructions until you see the remote device appeared in the remote list.

You should see status "Online" in the device list, if it does not,













  • There are cases where "Loaded: masked (Reason: Unit chrome-remote-desktop.service is masked.)" error occurs, if so, run sudo rm /lib/systemd/system/your_app.service  to remove the systemd service of the chrome-remote-desktop and reload the systemd daemon by running sudo systemctl daemon-reload. Re-check the status of the chrome-remote-desktop and active status should be achieved
3.  Modify the file /opt/google/chrome-remote-desktop/chrome-remote-desktop,  change variable FIRST_X_DISPLAY_NUMBER to the output value of the command echo $DISPLAY.

4. Apply the differences manually for the remaining changes mentioned here. Do not use the patch command to patch the file as it may cause failure.

5. Create Xsession file under the config profile of chrome remote desktop using the following command. echo "1" > ~/.config/chrome-remote-desktop/Xsession, where "1" is the $DISPLAY value output mentioned in step #3. (value may vary depending on devices)

6. Restart the chrome remote desktop daemon with sudo systemctl daemon-reload followed by sudo /etc/init.d/chrome-remote-desktop restart. Re-check the chrome remote desktop status by sudo systemctl status chrome-remote-desktop.


Appendix
1. This method does not support wayland, only support Xorg, make sure wayland support is disabled. Edit file /etc/gdm3/custom.conf, make sure WaylandEnable parameter is configured to false

2. When activating through chrome remote desktop UI is not working (e.g.: Unknown error), try using headless enable, navigate to the chrome remote desktop in the remote client, in the left hand side menu, choose "configure through SSH", copy the command provided

DISPLAY= /opt/google/chrome-remote-desktop/start-host --code="4/0AdQt8qgifMrurEQn65gbwYJOA3VrpusSF64i8Fwxfl9Nn6uL7L2KLUdw75HXhpFqlfGG-w" --redirect-url="https://remotedesktop.google.com/_/oauthredirect" --name=$(hostname)

You may need to re-generate the key if the time is expired, copy and paste it to the remote host, follow the setup netvigation to complete the remote host setup

Updated: 4/6/2024

As of chrome remote desktop version v121+,

1. Download the patch file

2. Remove the first 4 lines of the patch file

3. Navigate to /opt/google/chrome-remote-desktop, apply the patch by "sudo patch -Np1 -i /path/to/use_existing_session.patch", update the FIRST_X_DISPLAY_NUMBER variable to the one output using "echo $DISPLAY", and also update value of ~/.config/chrome-remote-desktop/Xsession to the DISPLAY value

4. Update the XSession to disable wayland, set WaylandEnable to false, run "sudo systemctl restart gdm3" to take effect.

5. Re-login Ubuntu (re-configure the chrome remote desktop where possible) "DISPLAY= /opt/google/chrome-remote-desktop/start-host --code="4/0AdLIrYeNopk9TMNaSyMPAXCr25kRpDPi5oUt9w7IJkC5ALTp75JlaKajanli3b3XQ_RDlw" --redirect-url="https://remotedesktop.google.com/_/oauthredirect" --name=$(hostname)"

Patch file backup


Updated: 30/6/2025

As of latest "Ubuntu chrome remote" current session solution, just follow the guide to apply the update of file "/opt/google/chrome-remote-desktop", following the instruction marked here , (backup as following)

rm ~/.config/chrome-remote-desktop/Xsession
echo $DISPLAY | tr -d ':' >> ~/.config/chrome-remote-desktop/Xsession && cd /opt/google/chrome-remote-desktop
sudo cp chrome-remote-desktop chrome-remote-desktop_bak
sudo wget -qO- "https://gist.githubusercontent.com/nightuser/2ec1b91a66ec33ef0a0a67b6c570eb40/raw/b09250dcc9a28f09de93192a948dffb4963c2aca/use_existing_session.patch" | tail -n +5 > ~/use_existing_session.patch
sudo patch -Np1 -i ~/use_existing_session.patch
rm ~/use_existing_session.patch
systemctl restart chrome-remote-desktop@$USER.service
systemctl enable chrome-remote-desktop@${USER}.service
systemctl status chrome-remote-desktop@$USER.service

Path file

References

  1. Use existing session chrome remote desktop patch (Note: the .patch file cannot applied directly to the origin "/opt/google/chrome-remote-desktop/chrome-remote-desktop" , manual applying the differences is necessary.)
  2. How to Install chrome-remote-desktop on Arch
  3. systemd: How to unmask a service whose unit file is empty
  4. Disable wayland support
  5. Sample configuration files