gcloud compute copy-files [[USER@]INSTANCE:]SRC [[[USER@]INSTANCE:]SRC …] [[USER@]INSTANCE:]DEST [--dry-run] [--force-key-file-overwrite] [--plain] [--ssh-key-file=SSH_KEY_FILE] [--strict-host-key-checking=STRICT_HOST_KEY_CHECKING] [--zone=ZONE] [--ssh-key-expiration=SSH_KEY_EXPIRATION | --ssh-key-expire-after=SSH_KEY_EXPIRE_AFTER] [GCLOUD_WIDE_FLAG …]
gcloud compute copy-files copies files between a virtual machine
instance and your local machine using the scp command. This command does not
work for Windows VMs.
To denote a remote file, prefix the file name with the virtual machine instance
name (e.g.,
example-instance:~/FILE). To
denote a local file, do not add a prefix to the file name (e.g.,
~/FILE).
If a file contains a colon (``:´´), you must specify it by either using an absolute path or a path that begins with ``./´´.
Under the covers, scp(1) or pscp (on Windows) is used to facilitate
the transfer.
gcloud compute copy-files example-instance:~/REMOTE-DIR ~/LOCAL-DIR --zone=us-central1-aTo copy files from your local host to a virtual machine, run:
gcloud compute copy-files ~/LOCAL-FILE-1 ~/LOCAL-FILE-2 example-instance:~/REMOTE-DIR --zone=us-central1-aUSER@]INSTANCE:]SRC [[[USER@]INSTANCE:]SRC …]USER@]INSTANCE:]DEST--dry-run--force-key-file-overwrite--plainssh(1)/scp(1)
flags. This flag is useful if you want to take care of authentication yourself
or use specific ssh/scp features.
--ssh-key-file=SSH_KEY_FILE~/.ssh/google_compute_engine.
--strict-host-key-checking=STRICT_HOST_KEY_CHECKINGSTRICT_HOST_KEY_CHECKING must be one of:
yes, no, ask.
--zone=ZONE
If not specified and the
property isn't set, you might be prompted to select a zone (interactive mode
only).
compute/zone
To avoid prompting when this flag is omitted, you can set the
property:
compute/zone
gcloud config set compute/zone ZONEA list of zones can be fetched by running:
gcloud compute zones listTo unset the property, run:
gcloud config unset compute/zoneCLOUDSDK_COMPUTE_ZONE.
--ssh-key-expiration=SSH_KEY_EXPIRATION--ssh-key-expire-after=SSH_KEY_EXPIRE_AFTER--access-token-file,
--account, --billing-project,
--configuration,
--flags-file,
--flatten, --format, --help, --impersonate-service-account,
--log-http,
--project, --quiet, --trace-token, --user-output-enabled,
--verbosity.
Run $ gcloud help for details.
gcloud alpha compute copy-filesgcloud beta compute copy-filesgcloud preview compute copy-files
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-05-27 UTC.