Adding your ssh public key to GCP

Before you launch VM instances, you need to upload your ssh public key in order to log on to the VM. If you don't have any ssh keys, you have to run the ssh-keygen command to generate a key pair (public key and private key). Let's assume you have a public key as ~/.ssh/id_rsa.pub and a private key as ~/.ssh/id_rsa

  1. Check your login user name by using the whoami command, then use gcloud compute config-ssh to upload your key via the following command:
$ whoami
saito

$ gcloud compute config-ssh --ssh-key-file=~/.ssh/id_rsa
  1. Check your ssh public key is registered as metadata:
$ gcloud compute project-info describe --format=json
{
"commonInstanceMetadata": {
"fingerprint": "fAqDGp0oSMs=",
"items": [
{
"key": "ssh-keys",
"value": "saito:ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDAr1cHrrONuaPgN20sXCPH8uT2lOjWRB3zEncOTxOI2lCW6DM6Mr31boboDe0kAtUMdoDU43yyMe4r734SmtMuh...

That's all. These are minimal configurations in order to launch a VM instance. So, let's launch some VM instances on this infrastructure.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.36.71