gcloud alpha compute copy-files

NAME
gcloud alpha compute copy-files - copy files to and from Google Compute Engine virtual machines via scp
SYNOPSIS
gcloud alpha 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]
DESCRIPTION
(ALPHA)gcloud alpha compute copy-files copies filesbetween 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 instancename (e.g.,example-instance:~/FILE). Todenote 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 eitherusing an absolute path or a path that begins with ``./´´.

Under the covers,scp(1) or pscp (on Windows) is used to facilitatethe transfer.

When the destination is local, all sources must be the same virtual machineinstance. When the destination is remote, all sources must be local.

EXAMPLES
To copy a remote directory '~/REMOTE-DIR' on the instance of 'example-instance'to '~/LOCAL-DIR' on the local host, run:
gcloudalphacomputecopy-filesexample-instance:~/REMOTE-DIR~/LOCAL-DIR--zone=us-central1-a

To copy files from your local host to a virtual machine, run:

gcloudalphacomputecopy-files~/LOCAL-FILE-1~/LOCAL-FILE-2example-instance:~/REMOTE-DIR--zone=us-central1-a
POSITIONAL ARGUMENTS
[[USER@]INSTANCE:]SRC [[[USER@]INSTANCE:]SRC …]
Specifies the files to copy.
[[USER@]INSTANCE:]DEST
Specifies a destination for the source files.
FLAGS
--dry-run
Print the equivalent scp/ssh command that would be run to stdout, instead ofexecuting it.
--force-key-file-overwrite
If enabled, the gcloud command-line tool will regenerate and overwrite the filesassociated with a broken SSH key without asking for confirmation in bothinteractive and non-interactive environments.

If disabled, the files associated with a broken SSH key will not be regeneratedand will fail in both interactive and non-interactive environments.

--plain
Suppress the automatic addition ofssh(1)/scp(1)flags. This flag is useful if you want to take care of authentication yourselfor use specific ssh/scp features.
--ssh-key-file=SSH_KEY_FILE
The path to the SSH key file. By default, this is~/.ssh/google_compute_engine.
--strict-host-key-checking=STRICT_HOST_KEY_CHECKING
Override the default behavior of StrictHostKeyChecking for the connection. Bydefault, StrictHostKeyChecking is set to 'no' the first time you connect to aninstance, and will be set to 'yes' for all subsequent connections.STRICT_HOST_KEY_CHECKING must be one of:yes,no,ask.
--zone=ZONE
The zone of the instance to copy files to/from.

If not specified and thecompute/zoneproperty isn't set, you might be prompted to select a zone (interactive modeonly).

To avoid prompting when this flag is omitted, you can set thecompute/zone property:

gcloudconfigsetcompute/zoneZONE

A list of zones can be fetched by running:

gcloudcomputezoneslist

To unset the property, run:

gcloudconfigunsetcompute/zone

Alternatively, the zone can be stored in the environment variableCLOUDSDK_COMPUTE_ZONE.

At most one of these can be specified:
--ssh-key-expiration=SSH_KEY_EXPIRATION
The time when the ssh key will be valid until, such as"2017-08-29T18:52:51.142Z." This is only valid if the instance is not using OSLogin. See $gcloud topicdatetimes for information on time formats.
--ssh-key-expire-after=SSH_KEY_EXPIRE_AFTER
The maximum length of time an SSH key is valid for once created and installed,e.g. 2m for 2 minutes. See $gcloud topic datetimes forinformation on duration formats.
GCLOUD WIDE FLAGS
These flags are available to all commands:--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.

NOTES
This command is currently in alpha and might change without notice. If thiscommand fails with API permission errors despite specifying the correct project,you might be trying to access an API with an invitation-only early accessallowlist. These variants are also available:
gcloudcomputecopy-files
gcloudbetacomputecopy-files

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-05-07 UTC.