# 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

* [Initializing the gcloud CLI](https://cloud.google.com/sdk/docs/initializing)
* [The gcloud CLI cheat sheet](https://cloud.google.com/sdk/docs/cheatsheet)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://0xcriminal.gitbook.io/about-me/cloudsec/setting-up-google-cloud-accounts/getting-started-with-gcloud.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
