/
Creating and Connecting to a GCP instance

Creating and Connecting to a GCP instance

1. Create a key pair

  1. Create your SSH key pair

  2. ssh-keygen -t rsa -f keys\ubuntu-box -C ubuntu -b 2048
    1. ubuntu is the default user for the ubuntu box (I’m sure this can be changed)

    2. Here the key pair are being stored in a keys folder

  3. Two parts of a key are generated, a public and a private key.

    1. You can distribute the public key, but there should be one and only one copy of the private key, so this is kept on your machine

2. Create a GCP instance

  1. Compute Engine / VM Instances / CREATE INSTANCE

  2. Specify the instance details

  3. Expand the security section

  4. Select ADD ITEM

  5. Paste into here the public key of the key pair

 

3. Connecting to the machine

Use the following command to connect to the machine

ssh -i <path to private key> <username>@<ip address>

So in the above example

ssh -i keys\ubuntu-box ubuntu@ww.xx.yy.zz