Skip to content

Instantly share code, notes, and snippets.

@horosin
Last active May 21, 2024 18:07
Show Gist options
  • Save horosin/82f1dbcff64c788df04ac5fad1d7b46c to your computer and use it in GitHub Desktop.
Save horosin/82f1dbcff64c788df04ac5fad1d7b46c to your computer and use it in GitHub Desktop.
Chrome Remote Desktop on Debian Server

Chrome Remote Desktop on Debian/Ubuntu Server

Get a remote connection to your cloud server! This utility script by default installs XFCE, Chrome and Chrome Remote Desktop.

Based on this guide, made ready to install with one command and use xfce by default.

Steps:

  1. Install requirements (please check if the script is safe before you execute this command!)
wget -qO- https://gist.githubusercontent.com/horosin/82f1dbcff64c788df04ac5fad1d7b46c/raw/install.sh | sudo bash
  1. (optional) Create and switch to a non-root user on your server and add it to sudo group
adduser remote
usermod -aG sudo remote
sudo su - remote
  1. Set up the connection - https://remotedesktop.google.com/headless

  2. Connect to your server from https://remotedesktop.google.com/

You're done!

#!/bin/bash -x
#
# Startup script to install Chrome remote desktop and a desktop environment.
#
# See environmental variables at then end of the script for configuration
#
function install_desktop_env {
PACKAGES="desktop-base xscreensaver"
if [[ "$INSTALL_XFCE" != "yes" && "$INSTALL_CINNAMON" != "yes" ]] ; then
# neither XFCE nor cinnamon specified; install both
INSTALL_XFCE=yes
INSTALL_CINNAMON=yes
fi
if [[ "$INSTALL_XFCE" = "yes" ]] ; then
PACKAGES="$PACKAGES xfce4"
echo "exec xfce4-session" > /etc/chrome-remote-desktop-session
[[ "$INSTALL_FULL_DESKTOP" = "yes" ]] && \
PACKAGES="$PACKAGES task-xfce-desktop"
fi
if [[ "$INSTALL_CINNAMON" = "yes" ]] ; then
PACKAGES="$PACKAGES cinnamon-core"
echo "exec cinnamon-session-cinnamon2d" > /etc/chrome-remote-desktop-session
[[ "$INSTALL_FULL_DESKTOP" = "yes" ]] && \
PACKAGES="$PACKAGES task-cinnamon-desktop"
fi
DEBIAN_FRONTEND=noninteractive \
apt-get install --assume-yes $PACKAGES
systemctl disable lightdm.service
}
function download_and_install { # args URL FILENAME
curl -L -o "$2" "$1"
dpkg --install "$2"
apt-get install --assume-yes --fix-broken
}
function is_installed { # args PACKAGE_NAME
dpkg-query --list "$1" | grep -q "^ii" 2>/dev/null
return $?
}
# Configure the following environmental variables as required:
INSTALL_XFCE=yes
INSTALL_CINNAMON=no
INSTALL_CHROME=yes
INSTALL_FULL_DESKTOP=no
# Any additional packages that should be installed on startup can be added here
EXTRA_PACKAGES="less bzip2 zip unzip terminator curl dbus-x11 pulseaudio vlc"
apt-get update
apt-get install --assume-yes $EXTRA_PACKAGES
! is_installed chrome-remote-desktop && \
download_and_install \
https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb \
/tmp/chrome-remote-desktop_current_amd64.deb
install_desktop_env
[[ "$INSTALL_CHROME" = "yes" ]] && \
! is_installed google-chrome-stable && \
download_and_install \
https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
/tmp/google-chrome-stable_current_amd64.deb
echo "Chrome remote desktop installation completed"
@ceewanna
Copy link

ceewanna commented Sep 8, 2023

Would this work for GNOME as well? Any changes to the script needed to make it work for GNOME?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment