1

I have two Google Compute Engine instances: instance-1 and instance-2, and I want to copy files from instance-1 to instance-2. Both instances are in the same project and zone.

In instance-1, I ran:

gcloud compute copy-files *.tar.bz2 instance-2:/mnt/pd1/home/ --zone  us-central1-b

and got this error message:

ERROR: (gcloud.compute.copy-files) Could not fetch instance: - Insufficient Permission

Running gcloud config list on both instances shows that they use the same service account:

Your active configuration is: [NONE]
[core]
account = [email protected]
disable_usage_reporting = True
project = abc-123

Is there a simple way to copy files between two VM instances without switching accounts (i.e., gcloud auth login)?

2 Answers 2

0

You can set the service account scopes for Google Cloud APIs when creating your GCE instance. By doing so your service account on this GCE instance will have the authorization to make API calls on your behalf. You can refer to this link for more information.

0

You can avoid overpermissioning the service account by logging in with your personal gcloud account.

me@instance-1: gcloud auth login
me@instance-1: gcloud compute scp instance-2:my-file.txt .

Assuming your personal gcloud account has the relevant permissions

gcloud auth revoke afterwards if others have access to this machine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .