Search code examples
google-cloud-platformgoogle-cloud-shell

Copy files from Google Cloud Shell to GCP VM


My development environment is within Google Cloud Shell, whereas the production environment is a separate GCP VM instance. After testing I would like to move all files from my dist folder to the GCP VM instance.

As a test I have tried to copy just one file.

Attempt #1: within Cloud Shell terminal

gcloud alpha cloud-shell scp cloudshell:~/README-cloudshell.txt peter@myvm:~/README-cloudshell.txt

Error #1: All sources must be local files when destination is remote.

Attempt #2: within GCP VM terminal

gcloud compute scp cloudshell:~/README-cloudshell.txt myvm:~

Error #2: All sources must be local files when destination is remote.

I appreciate any help.


Solution

  • from cloud shell

    gcloud compute scp ~/README-cloudshell.txt user@instanceName:~

    Use a correct SSH key or set the correct permission in the ~ directory