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

Viewed 11873

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

5 Answers

UPDATE

Try 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:

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

Use the below syntax to activate the service account. Here we need to mention service account ID. gcloud auth activate-service-account testpck@xxxxxx.iam.gserviceaccount.com --key-file=xxxxxx.json --project=xxxxxx

Use the below syntax to revoke the service account: gcloud auth revoke testpck@xxxxx.iam.gserviceaccount.com
Error encountered in your case because the service account ID was not mentioned in gcloud auth revoke command , which is trying to revoke your active google account.

Permissions are denied if you disable the service account instead of revoke. If you revoke the service account then default account will get activated and that might have permission to storage.

this error happens when you try to remove a service account that was propagated to the machine during the creation time (docs here). this service account could not be removed from your machine.

in any other case, the following commands should work (as mentioned in other answers here).

gcloud auth revoke --all

OR

gcloud auth revoke [ACCOUNT]

I may be late to the party on this, but the solution that I found works is:

gcloud config unset auth/impersonate_service_account

Followed by:

gcloud auth login

TLDR; To logout from all accounts

gcloud auth revoke --all

To check active account logins

gcloud auth list

To logout form one account only (take account from command above)

gcloud auth revoke [ACCOUNT]
Related