Setting up ssh keys

After you create new instances in the Developers Console, you can access them using:

When you connect using gcloud compute ssh, gcloud automatically handles creating an ssh key and inserting it into the instance.

If you want to use another ssh client without gcloud compute, you can insert your ssh key using the console. This is useful if you already have a public/private key pair and would like to use the same public/private key pair for your new instances.

To insert your keys using the Developers Console:

  1. Generate your keys using ssh-keygen or PuTTYgen for Windows, if you haven't already.
  2. Copy the contents of your public key. If you just generated this key, it can probably be found in a file named id_rsa.pub.
  3. Log in to the Developers Console.
  4. In the navigation, Compute->Compute Engine->Metadata.
  5. Click the SSH Keys tab.
  6. Click the Edit button.
  7. In the empty input box at the bottom of the list, enter the corresponding public key, in the following format:

    <protocol><public-key> username@example.com

    This makes your public key automatically available to all of your instances in that project. To add multiple keys, list each key on a new line.

  8. Click Done to save your changes.

    It can take several minutes before the key is inserted into the instance. Try connecting with ssh to your instance. If it is successful, your key has been propagated to the instance.