Search code examples
google-cloud-platformgcloud

gcloud auth activate-service-account logout / revoke / remove / unset


I,ve added my service-account successfuly using below command.

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

Now I can't remove or logout from it.

any help would be greatly appreciated.

edit: i tried this commands and got error

  1. gcloud auth revoke

ERROR: (gcloud.auth.revoke) Cannot revoke GCE-provided credentials.

  1. gcloud config configurations delete default

ERROR: (gcloud.config.configurations.delete) Deleting named configuration failed because configuration [default] is set as active. Use gcloud config configurations activate to change the active configuration.

edit2: this gcloud cli is on GCP ubuntu VM


Solution

  • UPDATE

    Use a command with a specified account because you can't revoke the Compute Engine service account(default).

    For example:

    gcloud auth revoke serviceaccount@testproject.iam.gserviceaccount.com
    

    and run:

    gcloud auth list
    

    It should only display the default service account of the Compute Engine:

    [PROJECT-NUMBER]-compute@developer.gserviceaccount.com