# Gcloud authentication fails

**URL:** <https://discuss.circleci.com/t/gcloud-authentication-fails/3871>\
**Category:** Build Environment\
**Tags:** gce\
**Created:** [May 9, 2016, 6:59am UTC](https://discuss.circleci.com/t/gcloud-authentication-fails/3871 "2016-05-09T06:59:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tnzk](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/tnzk/32/2204_2.png) [@tnzk](https://discuss.circleci.com/u/tnzk)\
**Post date:** [May 9, 2016, 6:59am UTC](https://discuss.circleci.com/t/gcloud-authentication-fails/3871/1 "2016-05-09T06:59:18Z")

</div>

I’m deploying Kubernetes apps to GKE through CircleCI these days, but today it fails with error that follows:

```sh
ubuntu@box241:~/myapp$ ./deploy/bin/gcp-auth-staging.sh
[INFO] GCP_CREDENTIALS_STAGING is found. Assuming it is base64-encoded.
ERROR: gcloud crashed (IOError): [Errno 13] Permission denied: '/home/ubuntu/.config/gcloud/configurations/config_default'

If you would like to report this issue, please run the following command:
  gcloud feedback
ERROR: gcloud crashed (IOError): [Errno 13] Permission denied: '/home/ubuntu/.config/gcloud/configurations/config_default'

If you would like to report this issue, please run the following command:
  gcloud feedback
ERROR: gcloud crashed (IOError): [Errno 13] Permission denied: '/home/ubuntu/.config/gcloud/configurations/config_default'

If you would like to report this issue, please run the following command:
  gcloud feedback
ERROR: gcloud crashed (IOError): [Errno 13] Permission denied: '/home/ubuntu/.config/gcloud/configurations/config_default'

If you would like to report this issue, please run the following command:
  gcloud feedback
ERROR: (gclusters.get-credentials) You do not currently have an active account selected.
Please run:

  $ gcloud auth login

to obtain new credentials, or if you have already logged in with a
different account:

  $ gcloud config set account ACCOUNT

to select an already authenticated account to use.

```

`gcloud auth activate-service-account` caused this. I tried changing the ownership of `/home/ubuntu/.config/gcloud/configurations/config_default` from `root:root` to `ubuntu:ubuntu` and it works.

I am then able to pass the authentication but discouraged to continue the deploy.

I have been successfully deploying by following the workround proposed here:

> [@Gcloud permissions error](https://discuss.circleci.com/t/gcloud-permissions-error/2631/6):
>
> Well, that failed as well: sudo /opt/google-cloud-sdk/bin/gcloud --quiet components update ./deploy.sh Your current Cloud SDK version is: 98.0.0 You will be upgraded to version: 100.0.0 ┌────────────────────────────────────────────────────────┐ │ These components will be updated. │ ├─────────────────────────────────┬────────────┬─────────┤ │ Name │ Version │ Size │ ├─────────────────────────────────┼────────────┼─────────┤ │ Cloud SDK Co…

It passed two weeks last time I have deployed the app. Something has changed since then?

---

<div class="post-metadata">

**Author:** ![FelicianoTech](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/felicianotech/32/21348_2.png) [@FelicianoTech](https://discuss.circleci.com/u/FelicianoTech)\
**Post date:** [May 9, 2016, 8:23pm UTC](https://discuss.circleci.com/t/gcloud-authentication-fails/3871/2 "2016-05-09T20:23:56Z")

</div>

Hi,

I can’t be sure what your deployment script is running but have you tried following along with the following guide? [https://circleci.com/docs/continuous-deployment-with-google-container-engine/](https://circleci.com/docs/continuous-deployment-with-google-container-engine/)

---

<div class="post-metadata">

**Author:** ![mastilver](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@mastilver](https://discuss.circleci.com/u/mastilver)\
**Post date:** [May 9, 2016, 11:47pm UTC](https://discuss.circleci.com/t/gcloud-authentication-fails/3871/3 "2016-05-09T23:47:27Z")

</div>

I’ve been following: [https://github.com/circleci/docker-hello-google](https://github.com/circleci/docker-hello-google) it’s working fine for me

---

<div class="post-metadata">

**Author:** ![tnzk](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/tnzk/32/2204_2.png) [@tnzk](https://discuss.circleci.com/u/tnzk)\
**Post date:** [May 10, 2016, 2:44am UTC](https://discuss.circleci.com/t/gcloud-authentication-fails/3871/4 "2016-05-10T02:44:19Z")

</div>

Hi,

My deploy script that fails is as follows:

```auto
#!/bin/bash

   SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
    REPO_ROOT=${SCRIPT_DIR}/../..

   PROJECT_ID=someprojectid
         ZONE=somezonename
 CLUSTER_NAME=someclustername
     GCR_HOST=asia.gcr.io
KEY_FILE_PATH=${REPO_ROOT}/deploy/secrets/client-secret.tmp.json

if [["$GCP_CREDENTIALS_STAGING" = ""]]
then
    cat ${REPO_ROOT}/deploy/secrets/secret-staging.json > ${KEY_FILE_PATH}
else
    echo $GCP_CREDENTIALS_STAGING | base64 --decode > ${KEY_FILE_PATH}
fi

gcloud auth activate-service-account --key-file ${KEY_FILE_PATH}
gcloud config set project $PROJECT_ID
gcloud config set compute/zone $ZONE
gcloud config set container/cluster $CLUSTER_NAME
gcloud container clusters get-credentials $CLUSTER_NAME

```

Thank you for giving me the guide. I could not found it at the time I was setting up my deploy scripts.

In the guide, it executes authentication in `dependencies.pre` phase.

[https://circleci.com/docs/continuous-deployment-with-google-container-engine/](https://circleci.com/docs/continuous-deployment-with-google-container-engine/)

I am running the script in `deployment` phase since I need to change an account to use regarding which branch is being deployed, by running respective scripts like [gcp-auth-staging.sh](http://gcp-auth-staging.sh) or [gcp-auth-production.sh](http://gcp-auth-production.sh)).

Sudo-ing `gcloud` in `deployment` phase seems to work.

I am very happy if there are any better ways.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:38am UTC](https://discuss.circleci.com/t/gcloud-authentication-fails/3871/5 "2018-06-18T11:38:20Z")

</div>

Closed on June 18, 2018, 11:38am UTC


