I spent way too much time trying to figure out how to copy files from the allocated Google Cloud Shell VM to my local machine. The cloud shell is great, but so is having a local copy.
Most of the time was spent trying to get some form of gcloud compute scp
to work, similar to this syntax:
$ gcloud compute scp some-instance:~/littlefile.zip ~/
However in addition to the compute
command, there is alpha cloud-shell
!
Approaches that did not work:
me@mylocalhost:~$ gcloud alpha cloud-shell scp ~/littlefile.zip .
ERROR: (gcloud.alpha.cloud-shell.scp) argument (cloudshell|localhost):SRC: Bad value [/home/me/littlefile.zip]: must start with cloudshell: or localhost:
me@mylocalhost:~$ gcloud alpha cloud-shell scp cloudshell:~/littlefile.zip localhost:~/littlefile.zip
~/littlefile.zip: No such file or directory
ERROR: (gcloud.alpha.cloud-shell.scp) [/usr/bin/scp] exited with return code [1].
Mention: How to copy files from google compute engine to local directory in case others find it but need Cloud Shell commands.
At the risk of "answering my own question," I actually just solved it! W00T!
Approaches that did work:
me@mylocalhost:~$ gcloud alpha cloud-shell scp cloudshell:littlefile.zip localhost:.
littlefile.zip 100% 16KB 253.1KB/s 00:00
me@mylocalhost:~$ gcloud alpha cloud-shell scp cloudshell:littlefile.zip localhost:littlefile.zip
littlefile.zip 100% 16KB 212.1KB/s 00:00
me@mylocalhost:~$ gcloud alpha cloud-shell scp cloudshell:~/adirectory/still-littlefile.zip localhost:.
still-littlefile.zip 100% 16KB 198.0KB/s 00:00