Setting up gcloud and authentication

Introduction

The Google Cloud CLI is a set of tools to create and manage Google Cloud resources. You can use these tools to perform many common platform tasks from the command line or through scripts and other automation.

What are we going to cover

In this chapter we shall cover the steps to setup and configure gcloud CLI access to your Google Cloud account.

Steps to setup gcloud CLI

gcloud is already installed on the student VM and the attacker machine. The Google Cloud CLI includes the gcloud, gsutil and bq command-line tools.

After you install the gcloud CLI, perform initial setup by running gcloud init.

The gcloud init perform Authorization and configuration setup steps.

Initialize the gcloud CLI

  • Run gcloud init:

gcloud init

If you are in a remote terminal session, you can use the --console-only flag to prevent the command from launching a browser-based authorization flow, if required:

gcloud init --console-only
  • Create or select a configuration if prompted.

  • Complete the authorization step when prompted.

  • Choose a current Google Cloud project if prompted or create a new project.

gcloud config set project <project-id>

Running gcloud CLI commands

Once you have completed the installation and initialization of the gcloud you can run some basic gcloud commands to check if it is configured properly and you have access to the Google Cloud resources.

For example, to list all the compute instances running in the current project run the below command

gcloud compute instances list

Additional information

Last updated