Cyberithub

How to use gcloud for GCP Login in 2 Best Steps

In this article, i will take you through the steps to use gcloud command for GCP Login.

The gcloud compute command-line tool enables you to easily manage your Compute Engine resources in a friendlier format than using the Compute Engine API. Before using the google interactive mode for our operations, we need to authenticate through google cloud authentication gcloud auth command. Commands like gcloud auth login is used for google cloud authentication.

How to use gcloud for GCP Login in 2 Best Steps 1

The gcloud tool is part of the Cloud SDK and is a unified command-line tool that includes features like statement autocompletion, in-place updating, extensive man page style help, human-readable and machine-parsable output formats, and integration with Cloud SDK

GCP Login

Let’s understand few basic things before going through the steps of GCP Login through gcloud command. I will go through basic understanding of what is google cloud login, how to use gcloud config set project after gcp login, google connect through ssh, what is google cloud login page, what is google cloud Authentication, how to use gcloud init and how to use gcloud auth login.

What is Google Cloud Authentication

Google Cloud Authentication is a mechanism through which a User authenticate in Google Cloud to perform certain Tasks and Operations using google cloud services and resources.

How to Open google cloud Login Page 

To open google cloud Login Page, you need to open any browser like Chrome, Firefox or Internet Explorer and provide https://console.cloud.google.com URL to open Google cloud Login Page.

How to perform Google Cloud Sign in

Once you opened the Google Cloud Login Page, you need to go to Google Cloud Sign in Page and provide your username and password and click on Login to perform Google Cloud Sign in.

How to use gcloud init Command

gcloud init command is used to initialize or reinitialize gcloud. Syntax of gcloud init can be given as:-

gcloud init [--console-only] [--skip-diagnostics] [GCLOUD_WIDE_FLAG …]

How to use gcloud config set project command

As reflected from the meaning of the command, gcloud config set project command is used to change the name of the project from default project name. Syntax of gcloud config set project command can be given as:-

gcloud config set project VALUE [--installation] [GCLOUD_WIDE_FLAG …]

How to perform gcloud auth login

You need to provide gcloud auth login command from the instance to authenticate the login.

[root@test ~]# gcloud auth login

You are running on a Google Compute Engine virtual machine.
It is recommended that you use service accounts for authentication.
You can run:

$ gcloud config set account `ACCOUNT`

to switch accounts if necessary.

Your credentials may be visible to others with access to this
virtual machine. Are you sure you want to authenticate with
your personal account?

Do you want to continue (Y/n)? y

Go to the following link in your browser:

https://accounts.google.com/o/oauth2/auth?code_challenge=JwGW0f87BVJGI-LTBXhiHKJKSFKCJgORm2_HwwfotSGcw&prompt=select_account&code_challenge_method=S256&access_type=offline&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&client_id=32555940559.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.test+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth

Once you go to above link, it will ask you to provide your google cloud credentials. Once provided, it will ask you to ‘allow’. Click on Allow and you will get below verification code to paste in the prompt:-

Enter verification code: 8/fQGO8asjisYH87sZY-UnNAELdjdksdss87HJcKbzvQPnC-Bj6SB8H34


You are now logged in as [test@example.com].
Your current project is [test-project]. You can change this setting by running:
$ gcloud config set project PROJECT_ID

I will change my project from default test-project to test1-project using below step:-

[root@test ~]# gcloud config set project test1-project
Updated property [core/project].

What about error “failed to authenticate with Google”

Sometimes you might have observed an error “failed to authenticate with Google” while trying to authenticate through google cloud authentication. Please check your credentials before proceeding to resolve this error.

Few Important gcloud Commands

gcloud components
gcloud components list
gcloud components remove
gcloud components repositories
gcloud components repositories add
gcloud components repositories list
gcloud components repositories remove
gcloud components restore
gcloud components update
gcloud compute config-ssh
gcloud compute copy-files
gcloud compute disks
gcloud compute disks create
gcloud compute disks delete
gcloud compute disks describe
gcloud compute disks list
gcloud compute disks snapshot
gcloud compute disk-types
gcloud compute disk-types describe
gcloud compute disk-types list
gcloud compute firewall-rules
gcloud compute firewall-rules create
gcloud compute firewall-rules delete
gcloud compute firewall-rules describe
gcloud compute firewall-rules list
gcloud compute firewall-rules update
gcloud compute forwarding-rules
gcloud compute forwarding-rules create
gcloud compute forwarding-rules delete
gcloud compute forwarding-rules describe
gcloud compute forwarding-rules list
gcloud compute forwarding-rules set-target
gcloud compute http-health-checks
gcloud compute http-health-checks create
gcloud compute http-health-checks delete
gcloud compute http-health-checks describe
gcloud compute http-health-checks list
gcloud compute http-health-checks update
gcloud compute images
gcloud compute images create
gcloud compute images delete
gcloud compute images deprecate
gcloud compute images describe
gcloud compute images list
gcloud compute instances
gcloud compute instances add-access-config
gcloud compute instances add-metadata
gcloud compute instances add-tags
gcloud compute instances attach-disk
gcloud compute instances create
gcloud compute instances delete
gcloud compute instances delete-access-config
gcloud compute instances describe
gcloud compute instances detach-disk
gcloud compute instances get-serial-port-output
gcloud compute instances list
gcloud compute instances remove-metadata
gcloud compute instances remove-tags
gcloud compute instances reset
gcloud compute instances set-disk-auto-delete
gcloud compute instances set-scheduling
gcloud compute instances start
gcloud compute instances stop
gcloud compute instance-templates
gcloud compute instance-templates create
gcloud compute instance-templates delete
gcloud compute instance-templates describe
gcloud compute instance-templates list
gcloud compute machine-types
gcloud compute machine-types describe
gcloud compute machine-types list
gcloud compute networks
gcloud compute networks create
gcloud compute networks delete
gcloud compute networks describe
gcloud compute networks list
gcloud compute operations
gcloud compute operations describe
gcloud compute operations list
gcloud compute project-info
gcloud compute project-info add-metadata
gcloud compute project-info describe
gcloud compute project-info remove-metadata
gcloud compute project-info set-usage-bucket
gcloud compute regions
gcloud compute regions describe
gcloud compute regions list
gcloud compute routes
gcloud compute routes create
gcloud compute routes delete
gcloud compute routes describe
gcloud compute routes list
gcloud compute snapshots
gcloud compute snapshots delete
gcloud compute snapshots describe
gcloud compute snapshots list
gcloud compute ssh
gcloud compute target-http-proxies
gcloud compute target-http-proxies create
gcloud compute target-http-proxies delete
gcloud compute target-http-proxies describe
gcloud compute target-http-proxies list
gcloud compute target-http-proxies update
gcloud compute target-instances
gcloud compute target-instances create
gcloud compute target-instances delete
gcloud compute target-instances describe
gcloud compute target-instances list
gcloud compute target-pools
gcloud compute target-pools add-health-checks
gcloud compute target-pools add-instances
gcloud compute target-pools create
gcloud compute target-pools delete
gcloud compute zones
gcloud compute zones describe
gcloud compute zones list
gcloud config
gcloud config list
gcloud config set
gcloud config unset
gcloud dns
gcloud help
gcloud info
gcloud init
gcloud sql
gcloud sql backups
gcloud sql backups describe
gcloud sql backups list
gcloud sql flags
gcloud sql flags list
gcloud sql instances
gcloud sql instances clone
gcloud sql instances create
gcloud sql instances delete
gcloud sql instances describe
gcloud sql instances export
gcloud sql instances import
gcloud sql instances list
gcloud sql instances patch
gcloud sql instances promote-replica
gcloud sql instances reset-ssl-config
gcloud sql instances restart
gcloud sql instances restore-backup
gcloud sql instances set-root-password
gcloud sql operations
gcloud sql operations describe
gcloud sql operations list
gcloud sql operations wait
gcloud sql ssl-certs
gcloud sql ssl-certs create
gcloud sql ssl-certs delete
gcloud sql ssl-certs describe
gcloud sql ssl-certs list
gcloud sql tiers
gcloud sql tiers list

You can Check the complete gcloud commands on gcloud command complete list.

Also Read: Oracle Cloud IaaS Set Up

For References: Google Cloud

Leave a Comment