[donotprint]
Tutorial details | |
---|---|
Difficulty | Easy (rss) |
Root privileges | No |
Requirements | gcloud sdk |
Time | 1m |
Syntax
The basic syntax is as follows to copy file from your local system to remote Google VM:
gcloud compute copy-files local-file-name {instance-name-here}:/path/ --zone {zone-name-here}
The basic syntax is as follows to copy file from remote Google VM to your local system
gcloud compute copy-files {instance-name-here}:/remote/path /local/dir/ --zone {zone-name-here} gcloud compute copy-files {instance-name-here}:/~filename /local/dir/ --zone {zone-name-here}
Examples
To list your Google compute VM, enter:
$ gcloud compute instances list
Sample outputs:
Fig.01: Note down the Google instance NAME and ZONE
$ gcloud compute copy-files /etc/hosts vivek@instance-1:~/ --zone us-central1-b
To copy local ~/webapp/ directory to remote vm called instance-1 hosted in us-central1-b zone, enter:
$ gcloud compute copy-files ~/webapp/ nginx@instance-1:/var/www/nginx/ --zone us-central1-b
To copy remote /foo/ directory from remote vm called instance-1 hosted in us-central1-b zone, enter:
$ gcloud compute copy-files USER@instance-1:/foo/ ~/backups/ --zone us-central1-b
To copy remote file ~/db.conf.py from remote vm called instance-1 hosted in us-central1-b zone, enter:
$ gcloud compute copy-files USER@instance-1:~/db.conf.py $HOME/data/ --zone us-central1-b
Options
You can pass the following options:
--dry-run : If provided, prints the command that would be run to standard out instead of executing it. --plain : Suppresses the automatic addition of ssh(1)/scp(1) flags. This flag is useful if you want to take care of authentication yourself or re-enable strict host checking. --ssh-key-file SSH_KEY_FILE : The path to the SSH key file. By default, this is ~/.ssh/google_compute_engine. --zone ZONE : The zone of the instance to copy files to/from. If omitted, you will be prompted to select a zone.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.
🐧 0 comments... add one ↓
🐧 0 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |