Try using gcloud compute scp
:
gcloud compute scp [[USER@]INSTANCE:]SRC [[[USER@]INSTANCE:]SRC …] [[USER@]INSTANCE:]DEST [--compress] [--dry-run] [--force-key-file-overwrite] [--plain] [--port=PORT] [--recurse] [--scp-flag=SCP_FLAG] [--ssh-key-file=SSH_KEY_FILE] [--strict-host-key-checking=STRICT_HOST_KEY_CHECKING] [--zone=ZONE] [GCLOUD_WIDE_FLAG …] [-h]
e.g.,
$ gcloud compute scp \ my-instance-1:~/file-1 \ my-instance-2:~/file-2 \ ~/my-destination \ --zone us-central2-a
As an alternative, you can also use (non-gcloud
) sftp
or scp
; see this SO answer for details on the command line arguments you need to specify, which I'll quote here for simplicity:
sftp -o IdentityFile ~/.ssh/google_compute_engine user@host
To use any other SFTP tool, similarly provide to it the path to the SSH private key and it will be able to connect to the instance. However, in the case of gcloud
, it can resolve the hostname to the public IP themselves; for all other tools, you'll need to find the IP manually and specify the IP address directly.