Google Cloud workstation

Assumptions

Create project

We need a Google Cloud project to own workstation VM instances. It's helpful to make it independent of other projects.

Create instance

In Google Cloud console:

  1. Nav to Compute Engine and create new micro instance
  2. Name "ubuntu"
  3. Region "us-west"
  4. Size "custom (1 vCPU, 4 GB memory)", so we have enough memory to install things like Ruby and IntelliJ
  5. OS ubuntu LTS
  6. Start instance
  7. Copy external IP address

SSH access

Enable laptop to connect to cloud instance. In Google Cloud console:

  1. Search for "SSH key" and select "metadata" result
  2. Copy public key contents from local machine using Text and paste into Cloud console https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys#project-wide
  3. Open Secure Shell on local machine, select key, paste IP address and connect

Desktop

The Chrome Remote Desktop (CRD) docs are pretty good, but assume you already have a desktop with Chrome running. For a cloud VM, we need a way to bootstrap without a desktop. A couple (1, 2) Chrome support threads were helpful. Steps:

  1. Install lightweight window manager

     sudo apt install -y xubuntu-desktop
    
  2. Download CRD

     wget https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb
    
  3. Install CRD

     sudo dpkg -i chrome-remote-desktop_current_amd64.deb
    
  4. Define ~/.chrome-remote-desktop:

     exec /usr/sbin/lightdm-session "startxfce4"
    

    Note: misconfiguration of this file (including misnaming) results in "… Session process terminated … " errors.

  5. Restart CRD to load the config:

     sudo /etc/init.d/chrome-remote-desktop restart
    
  6. Use http://remotedesktop.google.com/headless to generate the command required to register a host and set an access pin (credit), and then run this command on the workstation

    Note: we used to have to edit the Compute Engine instance firewall to enable udp:all and tcp:443,5222 open for ingress and egress, but this no longer seems required

  7. On the netbook, launch CRD app, select the host created above and enter the access pin you defined

Github

Define an SSH key pair to enable communication with Github:

  1. Define SSH key pair, per github SSH key generation docs:

     ssh-keygen -t rsa -b 4096 -C '<project>.<instance>@<cloud provider>'
    
  2. Copy public key contents into github settings

Feedback

Thoughts? Suggestions? Hit me up @erikeldridge

License

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 International License, and code samples are licensed under the MIT license.