NashTech Blog

Setting Up Google Cloud CLI & Service Account Authentication

Table of Contents

In the previous blog, we explored the fundamentals of cloud computing and how Google Cloud organizes resources using projects, regions, and zones. Cloud computing—especially with Google Cloud—offers flexibility, cost efficiency, and powerful services to help businesses grow faster.

Now that we have a solid understanding of how Google Cloud structures its resources, it’s time to get hands-on. In this blog, we’ll set up our local environment to start building with Google Cloud — beginning with installing the gcloud CLI, creating a service account, and connecting it to your project.

Step 1: Install Google Cloud CLI

To begin using GCP from the terminal, you need the gcloud CLI. Install it using Snap:

sudo snap install google-cloud-cli --classic

You can verify it installed successfully by checking the version:

gcloud version

Step 2: Create a Service Account and Download the Key

  • Give it a name, e.g., learning.
  • Assign necessary roles (for example: Viewer, Compute Admin, etc.).
  • After creation, click “Add Key” → “Create New Key”, choose JSON, and download it.

Save this JSON file securely. It’s your service account key.

Step 3: Authenticate Using the Service Account

Once you’ve downloaded the .json key file, authenticate with it:

gcloud auth activate-service-account --key-file=your-key-file.json

Example:

gcloud auth activate-service-account --key-file=celestial-tract-413511-c4bf1a8fa920.json

This sets the service account as the active identity for future commands.

Step 4: Set the Active Project

To tell gcloud which project you’re working with:

gcloud config set project PROJECT_ID

Example

gcloud config set project celestial-tract-413511

If you see a permission error, ensure your service account has at least Viewer or Editor access to the project.

Conclusion

You now have a working Google Cloud CLI setup, authenticated with a service account, and ready to interact with your project from the terminal. This setup is ideal for automation, scripting, or DevOps workflows.

In the next blog, we’ll look how to create services from console as well as from gcloud cli.

Picture of rupali1520

rupali1520

Leave a Comment

Suggested Article

Discover more from NashTech Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading