gcloud cloud-shell scp Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud cloud-shell scp - copies files between Cloud Shell and the local machine
- SYNOPSIS
gcloud cloud-shell scp(cloudshell|localhost):SRC[(cloudshell|localhost):SRC…](cloudshell|localhost):DEST[--dry-run][--force-key-file-overwrite][--recurse][--scp-flag=SCP_FLAG][--ssh-key-file][GCLOUD_WIDE_FLAG …]
- DESCRIPTION
gcloud cloud-shell scpcopies files between your Cloud Shellinstance and your local machine using the scp command.- EXAMPLES
- To denote a file in Cloud Shell, prefix the file name with the string"cloudshell:" (e.g.
cloudshell:~/FILE). To denote alocal file, prefix the file name with the string "localhost:" (e.g.localhost:~/FILE). For example,to copy a remote directory to your local machine, run:gcloudcloud-shellscpcloudshell:~/REMOTE-DIRlocalhost:~/LOCAL-DIRIn the above example,
fromyour Cloud Shell instance is copied into the ~/~/REMOTE-DIRLOCAL-DIRdirectory.Conversely, files from your local computer can be copied into Cloud Shell:
gcloudcloud-shellscplocalhost:~/LOCAL-FILE-1localhost:~/LOCAL-FILE-2cloudshell:~/REMOTE-DIRUnder the covers,
scp(1)or pscp (on Windows) is used to facilitatethe transfer. - POSITIONAL ARGUMENTS
- Specifies the files to copy.
- Specifies a destination for the source files.
cloudshell| localhost):SRC-[(cloudshell|localhost):SRC-…]">(cloudshell|localhost):SRC[(cloudshell|localhost):SRC…]cloudshell| localhost):DEST">(cloudshell|localhost):DEST- FLAGS
--dry-run- If provided, prints the command that would be run to standard out instead ofexecuting it.
--force-key-file-overwrite- If enabled gcloud will regenerate and overwrite the files associated with abroken SSH key without asking for confirmation in both interactive andnon-interactive environment.
If disabled gcloud will not attempt to regenerate the files associated with abroken SSH key and fail in both interactive and non-interactive environment.
--recurse- Upload directories recursively.
--scp-flag=SCP_FLAG- Extra flag to be sent to scp. This flag may be repeated.
--ssh-key-file- The path to the SSH key file. By default, this is
~/.ssh/google_compute_engine.
- 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 helpfor details. - NOTES
- These variants are also available:
gcloudalphacloud-shellscpgcloudbetacloud-shellscp
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.