Skip to content

Instantly share code, notes, and snippets.

@KharmaScribbles
Forked from packetpilot/gnome_chromote.sh
Created January 14, 2019 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KharmaScribbles/981e407ff8e4aef078478874f023781f to your computer and use it in GitHub Desktop.
Save KharmaScribbles/981e407ff8e4aef078478874f023781f to your computer and use it in GitHub Desktop.
headless ubuntu|debian + gnome, accessible via Chrome Remote Desktop
#!/bin/bash
# gnome and chrome and chrome remote desktop access
# chrome itself is not required, but is included here.
# other desktops can be used w/ light script changes.
# tested on:
# - ubuntu xenial GCE instance
# - debian stretch crostini container on a Pixelbook (eve)
# running ChromeOS v67.0.3383.0 (dev channel)
# _without_ being in developer mode
# DO NOT RUN as root/with `sudo`, but DO RUN as a sudoer.
GKEY=https://dl.google.com/linux/linux_signing_key.pub
CHROMOTEDEB=https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb
wget -q -O - "${GKEY}" | sudo apt-key add -
sudo sh -c 'echo "deb https://dl.google.com/linux/chrome/deb/ stable main" \
> /etc/apt/sources.list.d/google-chrome.list'
sudo apt-get update
sudo apt-get -y \
install gnome-session gnome-shell google-chrome-stable
wget "${CHROMOTEDEB}"
sudo dpkg -i chrome-remote-desktop_current_amd64.deb
rm chrome-remote-desktop_current_amd64.deb
sudo apt-get -f install -y
echo "exec /usr/bin/gnome-session" > /home/"${USER}"/.chrome-remote-desktop-session
sudo usermod -aG chrome-remote-desktop "${USER}"
cat <<EOF
Next, you need to: (source: Wernight on askubuntu.com)
1. Get an auth code by going to this URL from your (not-headless) machine:
https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/chromoting%20https://www.googleapis.com/auth/googletalk%20https://www.googleapis.com/auth/userinfo.email&redirect_uri=https://talkgadget.google.com/talkgadget/blank&response_type=code&client_id=440925447803-avn2sj1kc099s0r7v62je5s339mu0am1.apps.googleusercontent.com&access_type=offline&approval_prompt=force
(note the client ID is from chromium) and once allowed (on the blank page),
the authorization will be the code= parameter of the URL.
2. On the headless machine run:
/opt/google/chrome-remote-desktop/start-host --code="MY_AUTH_CODE" \
--redirect-url=https://talkgadget.google.com/talkgadget/blank \
--name="MY_REMOTE_NAME"
3. Enter your PIN twice.
4. Test your connection.
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment