Linux – permission denied when using service account with Google scp command

google-cloud-platformgoogle-compute-enginelinux

I want to use CircleCI to deploy my code to Compute Engine instance. I have created a Service Account user and use gcloud scp command below:

gcloud --quiet compute scp --recurse dev/test/ [DEST_INSTANCE]:/var/www/dev/dev/test --zone=northamerica-northeast1-a --project [PROJECT_NAME]

to upload files to var subfolder and the deployment fails with the error below:

scp: /var/www/dev/dev/test: Permission denied
ERROR: (gcloud.compute.scp) [/usr/bin/scp] exited with return code [1].
Exited with code 1

Now, I want to grant access to the service account but I don't see it in the list of users to grant access to when I use cat /etc/passwd. How can I grant permission to a service account? The roles I have assigned to this account is:
enter image description here

Best Answer

Please check the service account in use. There's one service account that's default for GCE and created by GCP. The other one is the one you created.

If you're using the one you created, have you authorized login for the service account using the JSON key file?

Related Topic