DESCRIPTION
gcloud compute config-ssh
makes SSHing to virtual machine instances easier
by adding an alias for each instance to the user SSH configuration
(~/.ssh/config
) file.
In most cases, it is sufficient to run:
$ gcloud compute config-ssh
Each instance will be given an alias of the form
NAME.ZONE.PROJECT
. For example, if example-instance
resides in
us-central1-a
, you can SSH to it by running:
$ ssh example-instance.us-central1-a.MY-PROJECT
On some platforms, the host alias can be tab-completed, making
the long alias less daunting to type.
The aliases created interface with SSH-based programs like
scp(1)
, so it is possible to use the aliases elsewhere:
$ scp ~/MY-FILE example-instance.us-central1-a.MY-PROJECT:~
Whenever instances are added, removed, or their external IP
addresses are changed, this command should be re-executed to
update the configuration.