How to copy files from Google Compute Engine to a local directory

I am trying to copy files from my instance to my local directory using the following command

gcloud compute scp <instance-name>:~/<file-name> ~/Documents/

However, it shows an error as follows

$ USER / Documents /: Is the directory

ERROR: (gcloud.compute.scp) [/ usr / bin / scp] exited with return code [1].

Copying from a local directory to GCE works fine.

I also checked the Stanford tutorial and google documentation.

I have another instance where there is no such problem.

I somewhat believe that this may be a problem with SSH keys.

What could be wrong?

+16
source share
3 answers

Your command is correct if the correct source and destination paths

, , Google Compute Engine .

$ gcloud compute scp vm1:~/.bashrc ~/Documents/
.bashrc                                          100% 3515     3.4KB/s   00:00

( GCE VM), :

$ gcloud compute scp ~/Documents/.bashrc vm1:~/temp/
.bashrc                                          100% 3515     3.4KB/s   00:00

$ gcloud compute scp ~/Documents/.bashrc vm1:~/.bashrc-new
.bashrc                                          100% 3515     3.4KB/s   00:00

gcloud scp, PATH. , gcloud scp, scp. , , .

scp

, , , , , , , . --recurse ( -r, scp), .

gcloud compute scp --recurse SRC_PATH DEST_PATH

+16

, , , GCE .

oyashi@oyashi-torch-instance:~$ gcloud compute scp oyashi-torch-instance:~/spring1617_assignment1.zip ~/Documents/

/home/oyashi/Documents/: ERROR: (gcloud.compute.scp) [/usr/bin/scp] [1].

. .

oyashi@oyashi:~/Documents$ gcloud compute scp oyashi-torch-instance:~/spring1617_assignment1.zip ~/Documents/

spring1617_assignment1.zip 100% 42 42,0 / 00:00

. . , .

+6

To copy files from the virtual machine to the desktop, you can simply connect to the virtual machine via SSH, and in the upper right corner there is a settings button, there you will find the option to download the file, just enter the path to the file.

If it is a folder, first archive the folder, then download it.

+5
source

Source: https://habr.com/ru/post/1680999/


All Articles