Accounts and Keys#

In this lab you’ll generate SSH keys (if you don’t have them already) and upload your public key to GitHub and Google Cloud. Doing this will enable you to use your GitHub repositories and simplify the process of SSH-ing into Google Instances.

Generate a Key Pair#

Danger

Don’t do this if you have keys already! It will overwrite them.

It’s important to generate a key in the environment where you’ll be doing work. The table will help you identify where:

Environment Where to generate a key
Windows Native On the Ubuntu prompt in the WLS2 VM
Mac Native On your system prompt
Linux Native On your system prompt
Remote and Local VM Inside the VM
Cloud Console and Editor On the cloud console prompt

In all cases you will should be generating your SSH key pair on an Ubuntu prompt.

Note

You don’t need a password on your SSH key if you’re establishing it on your own machine.

$ ssh-keygen -t rsa -b 4096 

Your key pair will be in ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub. To view your public key so that you can copy and paste it into GitHub run this command:

$ cat ~/.ssh/id_rsa.pub

Upload your Key to GitHub#

Follow these two guides on GitHub:

  1. Add a new SSH key

  2. Test the SSH connection

Put Your Key in Gcloud#

Follow the instructions in this guide to adding SSH keys to Google projects.