How To Create and Connect Google Compute Engine VM Instances

Like other IaaS providers google compute engine does not have a free trial. If you want to explore google compute engine, you can use the coupon codes provided by other companies. When you apply those coupon codes you will get credits to use compute engine.

In this tutorial I will explain how to create virtual machine on compute engine and how to connect it from windows and linux machines.

Getting started:

          1. Login to https://console.developers.google.com
          2. Select the project you created.
          3. Click VM instances option under compute compute engine

           4. Click create an instance option

              5. You will see a list of options.

options Description
Name Any user defined name
Metadata tags for your instance
Https and https It you want to allow traffic to your instance from port 80 and 8080, check the two http and https option
Zone select a zone nearest to your geographical area.
Machine type Slect a VM type for your requirements. In this tutorial I am going to select a VM with 1.7 gig of RAM.
Boot Disk leave that option to create a new one. You can choose the existing boot disk after creating you first VM
Image OS flavor of your choice. I am selecting RHEL .
Disk type there are two disk types. 1) standard with normal performance 2) SSD – better performance than the standard persistent disk.
Network leave it to default , since we are not going to create any virtual network
External Ip : If you want a static IP address for your VM , select static IP, or else select ephemeral, which will change after every shutdown and boot.

Once you filled up the above options click create.

You can see the activities when your VM is getting created.

7.Once you VM is created , you can see it in the dashboard.

No you have your instance in place. Next step is to connect to the instance. You won’t be able to connect to instances directly with ssh keys or password like you do in AWS and azure. First you need to create the ssh key using the google cloud SDK.

How to connect to Compute engine Virtual machine:

1. Download and install cloud SDK(gcutil)

2. Authenticate your machine with compute engine.

3. Create ssh key

4. Connect to VM from gcutil or other ssh clients like putty.

I have explained all the above steps below.

Windows:

1.Download the sdk installer from here https://dl.google.com/dl/cloudsdk/release/GoogleCloudSDKInstaller.exe

2.Install it by clicking run

3.SDK needs python installation in your system, if your system does not have python installed, it will ask for installing python during SDK installation. Install python and then proceed to python installation.

4.Once the installation is complete , google cloud SDK shell will open.

5.Execute the following command in the shell

gcloud auth login

6.it will take you to the authentication page in the browser. Accept the authentication and you r machine will be authenticated to your google computer services.

8.Now you have to configure you project with the SDK using the following command. You can get the project id from the compute console.

gcloud config set project 

9.You once configured your project , you can list the instances in that project using the following command,

gcutil listinstances 

Connecting to your instance

1.You need a ssh key pair to connect to your instance. This key can be created using gcutil. The key will be save in your systems .ssh folder. If there is no .ssh folder create one in your %HOMEPATH%

2.Run the following command to create a ssh key.

gcutil ssh 

Use your instance name in place of instance-name. In my case it is comtechies. When you execute the command it will ask for a passphrase. Enter any passphrase and create the key. Remember the passphrase because it will be needed to login to the machine.

3.Use the following command to ssh in to the machine

gcutil ssh comtechies

It will ask for the passphrase you created. Type in the passphrase and login to the account. By default you will have all the root privileges to run commands in the VM.

4.You can also connect the VM using ssh client like putty using the .ppk key generated in you .ssh folder.

0 Shares:
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like