✅ How to Install Google Cloud SDK & Login to GCP (All Methods)
🌟 Step 1 — Install Google Cloud SDK
Windows
Download installer:
https://cloud.google.com/sdk/docs/install
macOS
curl https://sdk.cloud.google.com | bash
exec -l $SHELL
Linux
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-367.0.0-linux-x86_64.tar.gz
tar -xf google-cloud-sdk-367.0.0-linux-x86_64.tar.gz
./google-cloud-sdk/install.sh
exec -l $SHELL
⚙️ Step 2 — Initialize Cloud SDK
gcloud init
🔐 GCP Login Methods
✅ Method 1 — Login Using Browser
gcloud auth login
✅ Method 2 — Login Without Browser (SSH Server)
gcloud auth login --no-launch-browser
You will get a URL → open it → paste code.
✅ Method 3 — Set Default Project
gcloud config set project PROJECT_ID
✅ Method 4 — Verify Login
gcloud config list
🎯 Method 5 — Application Default Credentials (ADC)
Used by SDKs / Terraform / APIs
gcloud auth application-default login
🔐 Method 6 — Service Account Login (Automation / CI-CD)
gcloud auth activate-service-account --key-file=key.json
gcloud config set project PROJECT_ID
🛑 Method 7 — Workload Identity Federation (Keyless Login)
gcloud auth login --cred-file=workload-identity-credential.json
🧠 Method 8 — Cloud Shell Login (No Install)
Go to:
https://console.cloud.google.com
Click Activate Cloud Shell ✅
🧩 Method 9 — Terraform + GCP Authentication
gcloud auth application-default login
🔐 Method 10 — Docker / Artifact Registry Login
gcloud auth configure-docker
💻 Method 11 — Login to GCP Git Repos
gcloud source repos clone REPO_NAME --project=PROJECT_ID
📌 Useful Commands
| Action | Command |
|---|---|
| List projects | gcloud projects list |
| Show active auth | gcloud auth list |
| Remove login | gcloud auth revoke |
| Update SDK | gcloud components update |