Skip to content

Instantly share code, notes, and snippets.

@antiops
Last active January 10, 2021 21:09
Show Gist options
  • Save antiops/940092ac8ada95eadb69236d7d19dc68 to your computer and use it in GitHub Desktop.
Save antiops/940092ac8ada95eadb69236d7d19dc68 to your computer and use it in GitHub Desktop.
Google Collab Remote Desktop

Setup

  1. Go Here and create a new notebook.
  2. Once in it click on the code box and enter the text below. (Edit USERNAME & PASSWORD with a simple username/password, youll need to enter the password when usig sudo).
! wget https://gist.githubusercontent.com/antiops/940092ac8ada95eadb69236d7d19dc68/raw/e5220f5ca7c153ace4c2c58709195fd43db7e555/setup-remote.sh  &> /dev/null
! chmod +x setup-remote.sh
! ./setup-remote.sh USERNAME PASSWORD
  1. Click the play button
  • During installation it will ask you to go Here. Click begin, then next, authorize it, then copy the Debian Linux output into the text box when prompted in Collab.
  • You will be asked to create a 6 digit pin, 123456 will suffice. This will be used to log in below.
  • After it completes you will be able to access the desktop through Here using the account that you authorized in the prior step.

Notes

Machines only last a couple hours up to half a day. You'll have to re start the setup for a new machine.

#! /bin/bash
USERNAME=$1
PASS=$2
printf "Installing Remote Desktop... " >&2
{
sudo useradd -m $USERNAME
sudo adduser $USERNAME sudo
echo '$USERNAME:$PASS' | sudo chpasswd
sed -i 's/\/bin\/sh/\/bin\/bash/g' /etc/passwd
sudo apt-get update
wget https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb
sudo dpkg --install chrome-remote-desktop_current_amd64.deb
sudo apt install --assume-yes --fix-broken
sudo DEBIAN_FRONTEND=noninteractive \
apt install --assume-yes xfce4 desktop-base
sudo bash -c 'echo "exec /etc/X11/Xsession /usr/bin/xfce4-session" > /etc/chrome-remote-desktop-session'
sudo apt install --assume-yes xscreensaver
sudo systemctl disable lightdm.service
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg --install google-chrome-stable_current_amd64.deb
sudo apt install --assume-yes --fix-broken
sudo apt install nautilus nano htop -y
sudo adduser $USERNAME chrome-remote-desktop
} &> /dev/null &&
printf "\nSetup Complete " >&2 ||
printf "\nError Occured " >&2
printf '\nCheck https://remotedesktop.google.com/headless'
printf '\nAuthorize through Debian Linux and paste below\n'
read -p "Paste Here: " CRP
su - $USERNAME -c """$CRP"""
printf 'Check https://remotedesktop.google.com/access/ \n\n'
if sudo apt upgrade -y &> /dev/null
then
printf "\n\nUpgrade Completed " >&2
else
printf "\n\nError Occured " >&2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment