Useful GCP commands

16 Aug 2023 1 minutes 101 words

A couple of useful GCP gcloud commands.

  1. check you are signed in a project in GCP gcloud auth login - login to a project, this will open you a browser to authenticate through it redirect back to console after
  2. gcloud compute ssh username@vmname --ssh-key-file=~/.ssh/google_vm
  3. gcloud iam service-accounts list show service accounts in the current GCP project
  4. export SERVICE_ACCOUNT=github-actions@your-system.iam.gserviceaccount.com
  5. gcloud compute scp --zone europe-central2-a --recurse ./layouts jump:~/public send a layout folder to a public folder in the VM named jump
  6. gcloud iam service-accounts describe $SERVICE_ACCOUNT
  7. add new priviliges to a service account
   gcloud projects add-iam-policy-binding your-system \\
   --member "serviceAccount:$SERVICE_ACCOUNT" \\
   --role "roles/serviceusage.serviceUsageViewer"