Skip to main content
Prepare an isolated Ubuntu VM to run Google Cloud commands without relying on Cloud Shell. This approach centralizes your workflows on a dedicated environment and gives you full control over the CLI configuration.

Table of Contents

  1. Launch the Ubuntu VM
  2. Install Prerequisites
  3. Add the Google Cloud SDK Repository
  4. Install the Google Cloud CLI
  5. Authenticate and Configure gcloud
  6. Optional Configuration
  7. References

Launch the Ubuntu VM

  1. In your Playgrounds console, choose Ubuntu.
  2. Click Launch Now.
  3. Wait until the VM status shows Ready.
Assign a static external IP if you need consistent SSH access over time.

Install Prerequisites

SSH into your new VM and install the required packages:

Add the Google Cloud SDK Repository

  1. Import Google’s public key for APT:
  2. Add the Cloud SDK repo to your sources list:

Install the Google Cloud CLI

Update the package index and install the SDK:
Wait for the installation to finish; you’ll now have access to gcloud, gsutil, and other SDK components.

Authenticate and Configure gcloud

Run the initialization wizard:
Follow these steps:
  1. Select or create a configuration (press Enter for [default]).
  2. Choose an account:
  3. Approve usage of a personal account (Y).
  4. Authorize:
    • Copy the URL shown in your terminal.
    • Open it in an incognito/private browser window.
    • Sign in with your Google credentials.
    • Grant permissions and copy the authorization code.
  5. Paste the code back into the terminal.
  6. Select your project ID:
  7. (Optional) Set default region/zone now or skip.
Do not share your authorization code. Anyone with this code can access your Google Cloud resources.

Optional Configuration

Use these commands to set your default compute region and zone: You can always update these later with gcloud config set.

References

Watch Video