rsync zu Google Cloud VM-Instanz über Kommandozeile

English Deutsch

Wenn du dich mit SSH von deiner Kommandozeile mit einer Google Cloud VM-Instanz verbinden möchtest (my-instance in diesem Beispiel), verwende diesen Befehl:

rsync_gcloud.sh
rsync -Pavz [local file] $(gcloud compute instances list --filter="name=my-instance" --format "get(networkInterfaces[0].accessConfigs[0].natIP)"):

The subcommand (enclosed in $(...) ) finds the correct external IP address for your instance (see How to find IP address of Google Cloud VM instance on command line for more details), so this command boils down to for example

rsync_gcloud_example.sh
rsync -Pavz [local file] 35.207.77.101:

Using the -Pavz option is not specifically neccessary but these are the options I regularly use for rsync file transfers. You can use any rsync options, Google Cloud does not impose any specific restrictions here. For reference see the rsync manpage.

Falls du einen anderen Benutzernamen für den SSH-Login verwenden möchtest, kannst du den $(...)-Abschnitt natürlich wie folgt voranstellen:

rsync_gcloud_user.sh
rsync -Pavz [local file] sshuser@$(gcloud compute instances list --filter="name=my-instance" --format "get(networkInterfaces[0].accessConfigs[0].natIP)"):

Check out similar posts by category: Cloud