FreeZey
FreeZey

Reputation: 2812

Can you stop Google Cloud Shell prompting for "Authorise Cloud Shell" when running gcloud commands?

When running certain gcloud commands in Google Cloud Shell, e.g.

The following popup appears:

enter image description here

Is there a way to stop or auto accept this prompt?

I'd like to run some automation through Cloud Shell and this popup interrupts the process. I'm not sure why it's needed because the same commands can be run on a locally installed SDK without any interruption. In both cases the active users are the same and I've also experimented with service accounts but I get the same results.

When I script the process to use a service account (json key, activate, use account) I can even click on "Reject" authorization and it still works. Suggesting this prompt isn't providing any useful security.

Does anyone have any ideas? Thanks.

Upvotes: 2

Views: 1342

Answers (1)

RJC
RJC

Reputation: 1338

I'm not sure why it's needed because the same commands can be run on a locally installed SDK without any interruption.

The reason why auth prompts appear per session is that Cloud Shell is ephemeral, and it attempts to access Google APIs on behalf of user. Any user account who attempts to access Cloud APIs are subjected to a user consent screen, hence what you see in the console. For additional details, you can check this link.

For this, when you make a Google Cloud API call or use a command-line tool that requires credentials (such as the gcloud command-line tool, bq, gsutil, etc.) with Cloud Shell for the first time, Cloud Shell prompts you with the 'Authorize Cloud Shell' dialog. Just as what was stated here.

When you start Cloud Shell, it provisions a Google Compute Engine virtual machine running a Debian-based Linux operating system. Cloud Shell instances are provisioned on a per-user, per-session basis. The instance persists while your Cloud Shell session is active; after an hour of inactivity, your session terminates and its VM, discarded. See here for other details.

Cloud Shell is designed for interactive use only, so it may not match your use case if you're running automations, my suggestion is to continue using Cloud SDK on your machine. For further details, you can also check here.

Upvotes: 1

Related Questions