gcloud compute os-login ssh-keys update --ttl=TTL (--key=KEY | --key-file=KEY_FILE) [GCLOUD_WIDE_FLAG …]
gcloud compute os-login ssh-keys update accepts either a string
containing an SSH public key or a filename for an SSH public key, and updates
the key in the user's OS Login profile. Currently, only the expiration time,
--ttl, can be updated.
/home/user/.ssh/id_rsa.pub
with an expiration time of one week from now, run:
gcloud compute os-login ssh-keys update --ttl=7d --key-file=/home/user/.ssh/id_rsa.pubTo update the SSH public key with a fingerprint of 'e0d96d6fad35a61a0577f467940509b5aa08b6dea8d99456ec19a6e47126bc52' and an expiration time of five years from now, run:
gcloud compute os-login ssh-keys update --ttl=5y --key='e0d96d6fad35a61a0577f467940509b5aa08b6dea8d99456ec19a6e47126bc52'--ttl=TTL30m will set the expiration time on the SSH
key for 30 minutes from the current time. A value of 0 will result in no
expiration time. See $ gcloud
topic datetimes for information on duration formats.
--key=KEY--key-file=KEY_FILE--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 help for details.
gcloud alpha compute os-login ssh-keys updategcloud beta compute os-login ssh-keys update
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-05-27 UTC.