gcloud compute ssh
INSTANCE
--command
COMMAND
]--container
CONTAINER
]--dry-run
]--format
FORMAT
]--help
]--plain
]--project
PROJECT_ID
]--quiet
, -q
]--ssh-flag
SSH_FLAG
]--ssh-key-file
SSH_KEY_FILE
]--zone
ZONE
]-h
]gcloud compute ssh
is a thin wrapper around the ssh(1)
command that
takes care of authentication and the translation of the
instance name into an IP address.ssh-keygen(1)
.INSTANCE
USER
specifies the username with which to SSH. If omitted,
$USER from the environment is selected.--command
COMMAND
--container
CONTAINER
--dry-run
--plain
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-flag
SSH_FLAG
ssh(1)
. It is recommended that flags
be passed using an assignment operator and quotes. This flag will
replace occurences of %USER%
and %INSTANCE%
with their
dereferenced values. Example:
$ gcloud compute ssh example-instance --zone us-central1-a \ --ssh-flag="-vvv" --ssh-flag="-L 80:%INSTANCE%:80"
--vvv
and _-L
80:162.222.181.197:80_
to ssh(1)
if the external IP address of
example-instance
is 162.222.181.197.--ssh-key-file
SSH_KEY_FILE
~/.ssh/google_compute_engine
.
--zone
ZONE
compute/zone
property:$ gcloud config set compute/zone ZONE
$ gcloud compute zones list
$ gcloud config unset compute/zone
CLOUDSDK_COMPUTE_ZONE
.--format
FORMAT
json
, text
, yaml
.
--help
--project
PROJECT_ID
--quiet
, -q
-h
example-instance
in zone us-central1-a
, run:$ gcloud compute ssh example-instance --zone us-central1-a
$ gcloud compute ssh example-instance --zone us-central1-a \ --command "ps -ejH"
$ gcloud compute ssh example-instance --zone us-central1-a \ --container CONTAINER
compute
component. See
installing components
if it is not installed.