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.

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:

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.

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.

1

gcloud config set project<project-></project-id>

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

1

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.

1

gcutil ssh<instance-name></instance-name>

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

1

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.