Table of Contents
- Launch the Ubuntu VM
- Install Prerequisites
- Add the Google Cloud SDK Repository
- Install the Google Cloud CLI
- Authenticate and Configure
gcloud - Optional Configuration
- References
Launch the Ubuntu VM
- In your Playgrounds console, choose Ubuntu.
- Click Launch Now.
- 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:| Package | Purpose |
|---|---|
| apt-transport-https | Enables APT to use repositories accessed via HTTPS |
| ca-certificates | Provides SSL certificates |
| gnupg | Manages GPG keys |
| curl | Downloads files from the command line |
Add the Google Cloud SDK Repository
-
Import Google’s public key for APT:
-
Add the Cloud SDK repo to your sources list:
Install the Google Cloud CLI
Update the package index and install the SDK:gcloud, gsutil, and other SDK components.
Authenticate and Configure gcloud
Run the initialization wizard:
- Select or create a configuration (press Enter for
[default]). - Choose an account:
- Approve usage of a personal account (
Y). - 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.
- Paste the code back into the terminal.
- Select your project ID:
- (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:| Setting | Command |
|---|---|
| Default Compute Region | gcloud config set compute/region YOUR_REGION |
| Default Compute Zone | gcloud config set compute/zone YOUR_ZONE |
gcloud config set.