Chromoting GUI access on a Google Cloud Compute Engine running Linux OS using Chrome Remote Desktop

Aman Puri
Google Cloud - Community
6 min readMar 17, 2023

Google Cloud offers Google Compute Engine (GCE) which is a solution for hosting Virtual Machines in GCP. A lot Linux based/Windows based OS options are available to host on the VMs. In Linux VMs, while we have options to SSH into the instances, sometimes there is a requirement to have a GUI based access to these VMs. While there are many ways to set up GUI by installing the GUI solution and then unblocking the firewall rules, a more secure and better approach is by using Chrome Remote Desktop.

Chrome Remote Desktop is a remote desktop software tool, developed by Google, that allows a user to remotely control another computer’s desktop through a proprietary protocol also developed by Google, internally called Chromoting. The way is to utilize your Gmail ID to provision the system to you and then securely take the remote of the system. This can be used for both Windows and Linux devices. If you have a Linux-based GCP VM, you can do so with the following steps:

  1. Go to the Google Cloud Console in the Compute Engine section. You can/already have a GCP VM created with OS like Debian,Ubuntu etc.. Click on SSH to go inside the VM.
Google Cloud Console showing Compute Engine VM

2. Clicking on the SSH will open a new tab/window and you will screen like the image below. This means that you are inside the VM.

Compute Engine SSH Window

3. The next step is to install Chrome Remote Desktop in the VM. To do so, run the following set of commands. The setup will insta;; Chrome Remote Desktop in the VM which will take around a minute.

sudo apt update
curl -L -o chrome-remote-desktop_current_amd64.deb \
https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb
sudo DEBIAN_FRONTEND=noninteractive \
apt-get install --assume-yes ./chrome-remote-desktop_current_amd64.deb

4. Next, you need to install an X Window System desktop environment and window manager for Chrome Remote Desktop to use. Common options are:

You can use any one of the options and run the following script in the system depending on each option. The set of commands will:

  • Install the option you want to use for the Desktop environment
  • Set up the desktop environment with Chrome Remote Desktop
  • Because there is no display connected to your instance, disable the display manager service on your instance (Xfce only)
  • Disable the Gnome display manager service on your instance, because it conflicts with the Chrome Remote Desktop service and reboot the VM and then reconnect the VM (Gnome and Gnome-Classic only)
  • Install the full suite of Linux desktop applications, including the Firefox browser, LibreOffice office application suite, and the Evince PDF viewer (Xfce and Cinnamon only)
  • Install the Chrome browser on your instance

Note: You might see a Permission Denied error for the update-initramfs process during the installation process. This is normal and you can ignore the error.

Xfce:

sudo DEBIAN_FRONTEND=noninteractive \
apt install --assume-yes xfce4 desktop-base dbus-x11 xscreensaver
sudo bash -c 'echo "exec /etc/X11/Xsession /usr/bin/xfce4-session" > /etc/chrome-remote-desktop-session'
sudo systemctl disable lightdm.service
sudo apt install --assume-yes task-xfce-desktop
curl -L -o google-chrome-stable_current_amd64.deb \
https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install --assume-yes ./google-chrome-stable_current_amd64.deb

Cinnamon:

sudo DEBIAN_FRONTEND=noninteractive \
apt install --assume-yes cinnamon-core desktop-base dbus-x11
sudo bash -c 'echo "exec /etc/X11/Xsession /usr/bin/cinnamon-session-cinnamon2d" > /etc/chrome-remote-desktop-session'
sudo apt install --assume-yes task-cinnamon-desktop
curl -L -o google-chrome-stable_current_amd64.deb \
https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install --assume-yes ./google-chrome-stable_current_amd64.deb

Gnome:

sudo DEBIAN_FRONTEND=noninteractive \
apt install --assume-yes task-gnome-desktop
sudo bash -c 'echo "exec /etc/X11/Xsession /usr/bin/gnome-session" > /etc/chrome-remote-desktop-session'
sudo systemctl disable gdm3.service
sudo reboot
curl -L -o google-chrome-stable_current_amd64.deb \
https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install --assume-yes ./google-chrome-stable_current_amd64.deb

Gnome-Classic:

sudo DEBIAN_FRONTEND=noninteractive \
apt install --assume-yes task-gnome-desktop
sudo bash -c 'echo "exec /etc/X11/Xsession /usr/bin/gnome-session-classic" > /etc/chrome-remote-desktop-session'
sudo systemctl disable gdm3.service
sudo reboot
curl -L -o google-chrome-stable_current_amd64.deb \
https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install --assume-yes ./google-chrome-stable_current_amd64.deb

KDE Plasma:

sudo DEBIAN_FRONTEND=noninteractive \
apt install --assume-yes task-kde-desktop
sudo bash -c 'echo "exec /etc/X11/Xsession /usr/bin/startplasma-x11" > /etc/chrome-remote-desktop-session'
curl -L -o google-chrome-stable_current_amd64.deb \
https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install --assume-yes ./google-chrome-stable_current_amd64.deb

5. Next step is to configure Chrome Remote Desktop application to configure access to the VM. In your local computer using your chrome browser, go to https://remotedesktop.google.com/headless and sign-in with your Gmail ID. You should a screen similar to the image below. In the left, go to Set up via SSH session. Click on Begin in Set up another computer.

Chrome Remote Desktop Window

6. You will see links for installing CRD for Windows and Linux VMs. Since, we already did in the previous steps, click on Next.

Set up CRD in another computer

7. We will now authorize the VM to use CRD. Click on Authorize

Authorize Screen for CRD window

8. You will see a set of generated commands for Windows and Linux OS. Copy the command for the Linux OS.(Note: The command that is generated in this step is only available for a limited time. Once the time is past, you may face an error. In this case, you need to just go back to Start Again below and click on Authorize again).

Commands screen in CRD window

9. Go back to the VM’s SSH window and run the command. The command will ask you to set a 6-digit pin. Set the pin and it should be ready.

SSH command to Authorize CRD

10. Going back to your local computer, when you go to Remote Access in the CRD window, you will see the VM available in the list. Click on it, to Connect to the VM.

Remote Access Window in CRD

11. CRD will ask to enter a pin. Enter the 6–digit pin you set up in Step 9

Enter Pin in CRD window

12. You will have logged in your Linux VM’s GUI. You can now go to Application Finder and see Google Chrome already available to use. Note: You might get a window pop-upto enter the password for root. You can cancel that as it is not required.

Xfce Window for Linux VM

As you can see, it’s very easy to set up for Linux VMs and you can use to performing any GUI based activities for your application testing.

Thanks for Reading! 😊

References:

The steps are also mentioned in the following official Cloud Blog link

--

--