How to Install and Authenticate gcloud cli for Google cloud projects

You might be familiar with configuring AWS CLI on your Linux machine. Similarly, we can configure gcloud cli in our Linux machine and run gcloud command against our Google cloud to create and manage services.

In this demo, I will install gcloud CLI on my local Ubuntu 22 machine and authenticate it with my test project.

Working of gcloud cli

When a user runs a command example gcloud compute instances list,
gcloud retrieves stored credentials to obtain an access token.
GCP then checks IAM policies to ensure the user has the necessary compute.instances.list permission.
If authorized, gcloud sends an authenticated HTTP GET request to the Compute Engine API.
The API processes this request and returns a list of instances, which gcloud then formats and displays in the terminal


  • You must have a Google Cloud account.
  • You must have sudo access to your machine.

The gcloud CLI is available in package format for installation on Debian and Ubuntu systems. This package contains the gcloudgcloud alphagcloud betagsutil, and bq commands only. It doesn’t include kubectl or the App Engine extensions required to deploy an application using gcloud commands.

Step1: Update the packages

Step 2: Make sure it has curl and apt-transport-https installed.

Step 3: Import the Google Cloud public key.

Step 4: Add the gcloud CLI distribution URI as a package source.

Step 5: Update and install the gcloud CLI:

Step 6: Authenticating with our GCP project.

This will proceed to a login page where you can log in to your Google Cloud account and select the project.

A temporary URL will be generated on the terminal where you can copy and access it on the browser as shown in the screenshot below

Your browser will ask to allow access to Google Cloud SDK as shown below you can allow the permissions.

After that, a successful message will be shown on your screen as shown below mentioning that you have successfully authenticated with gcloud CLI.

Now if you come back to your terminal you will be able to see your Google Cloud projects listed as shown below.

You can select your working project and run gcloud command to create and manage resources.

In this article we have learned how to install gcloud cli on your local machine and authenticate with your Google Cloud project.

Leave a Reply

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