andrew
andrew

Reputation: 619

how copy / scp files via gsutil to google cloud VM?

I am playing with linux VM in GCP. Any idea how copy files from local machine to GCP VM via scp gsutil SDK ?

this command not working:

gcloud beta compute scp file user@test01:
ERROR: (gcloud.beta.compute.scp) Could not fetch resource:
 - The resource 'projects/pyton-app/zones/europe-west3-a/instances/test01' was not found

But I can login via ssh with below gsutil command

Cloud beta compute ssh --zone "europe-west3-c" "test01" --project "pyton-app"

Here are other options:

gcloud beta compute scp 
ERROR: (gcloud.beta.compute.scp) argument [[USER@]INSTANCE:]SRC [[[USER@]INSTANCE:]SRC ...] [[USER@]INSTANCE:]DEST: Must be specified.
Usage: gcloud beta compute scp [[USER@]INSTANCE:]SRC [[[USER@]INSTANCE:]SRC ...] [[USER@]INSTANCE:]DEST [optional flags]
  optional flags may be  --compress | --dry-run | --force-key-file-overwrite |
                         --help | --internal-ip | --plain | --port | --recurse |
                         --scp-flag | --ssh-key-expiration |
                         --ssh-key-expire-after | --ssh-key-file |
                         --strict-host-key-checking | --tunnel-through-iap |
                         --zone

...yes, instance is in this project as I can login via ssh, but unable to copy via scp.. trying also your advice command, but not working also

gcloud beta compute scp r.script user@test01:/tmp  --project "pyton-app"
ERROR: (gcloud.beta.compute.scp) Could not fetch resource:
 - The resource 'projects/pyton-app/zones/europe-west3-a/instances/test01' was not found

Tried also 2nd option, not working also

gcloud compute scp r.script user@test01:/tmp  --project "pyton-app"
ERROR: (gcloud.compute.scp) Could not fetch resource:
 - The resource 'projects/pyton-app/zones/europe-west3-a/instances/test01' was not found

Upvotes: 0

Views: 2558

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 75715

You aren't in the correct zone.

Look at the error message

- The resource 'projects/pyton-app/zones/europe-west3-a/instances/test01' was not found

-> europe-west3-a

Look at your ssh command

gcloud beta compute ssh --zone "europe-west3-c" "test01" --project "pyton-app"

-> europe-west3-c

For solving this, 2 solutions:

  • Add the zone in your scp command
gcloud beta compute scp --zone "europe-west3-c" file user@test01:
  • Set the zone by default in your gcloud config
gcloud config set compute/zone europe-west3-c

Upvotes: 1

Related Questions