In this guide we start with creating google cloud instance, let us see how to create VM command line using the gshell.
Log in to the Google cloud platform account, start the shell from right to the corner and follow below steps to create an instance from command line.
$ gcloud compute instances create gcelab2 –zone us-central1-c
Welcome to Cloud Shell! Type "help" to get started. google129866@6fbfd8bb66b05a0d:~$ gcloud compute instances create gcelab2 --zone us-central1-c Created [https://www.googleapis.com/compute/v1/projects/babin-gcp-a43bb87959e02885/zones/us-central1-c/instances/instance1]. NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS gcelab2 us-central1-c n1-standard-1 10.1.x.x 104.xxx.xxx.116 RUNNING google129866@6fbfd8bb66b05a0d:~$
Login to the created instance using Gcloud compute ssh command.
$ gcloud compute ssh gcelab2 –zone us-central1-c
google129866@6fbfd8bb66b05a0d:~$ gcloud compute ssh gcelab2 --zone us-central1-c WARNING: The public SSH key file for gcloud does not exist. WARNING: The private SSH key file for gcloud does not exist. WARNING: You do not have an SSH key for gcloud. WARNING: SSH keygen will be executed to generate a key. This tool needs to create the directory [/home/google129645_babin/.ssh] before being able to generate SSH keys. Do you want to continue (Y/n)? Y Generating public/private rsa key pair. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/google129645_babin/.ssh/google_compute_engine. Your public key has been saved in /home/google129645_babin/.ssh/google_compute_engine.pub. The key fingerprint is: f7:ec:53:8e:ff:1d:34:b0:81:c9:d4:b8:45:93:96:ac google129645_babin@cs-6000-devshell-vm-aa762148-1376-48aa-beec-9eddd8888097 The key's randomart image is: +---[RSA 2048]----+ | .=oo | | o.oB. | | +=o | | E + | | S . . o | | . o o .| | o+ . | | .o . o| | .o..o| +-----------------+ Updating project ssh metadata...-Updated [https://www.googleapis.com/compute/v1/projects/babin-gcp-a43bb87959e02885]. Updating project ssh metadata...done. Waiting for SSH key to propagate. Warning: Permanently added 'compute.8233552639093627032' (ECDSA) to the list of known hosts. Linux instance1 4.9.0-4-amd64 #1 SMP Debian 4.9.51-1 (2017-09-28) x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. google129645_babin@instance1:~$
To know more options available for Gcloud command user commands in below format.
# gcloud compute –help
That’s it we have launched a Google cloud instance from the command line using GCP Shell.