gcloud compute os-login ssh-keys add Archived: 2026-04-29 07:32:01 UTC gcloud compute os-login ssh-keys add Stay organized with collections Save and categorize content based on your preferences. NAME gcloud compute os-login ssh-keys add - add an SSH public key to an OS Login profile SYNOPSIS gcloud compute os-login ssh-keys add ( --key = KEY     | --key-file = KEY_FILE ) [ --ttl = TTL ] [ GCLOUD_WIDE_FLAG … ] DESCRIPTION gcloud compute os-login ssh-keys add accepts either a string containing an SSH public key or a filename for an SSH public key and adds that key to the user's OS Login profile. EXAMPLES To add the key in /home/user/.ssh/id_rsa.pub to your OS Login profile, run: See more code actions. gcloud compute os-login ssh-keys add --key-file=/home/user/.ssh/id_rsa.pub To add the same key, but with a one year expiration time, run: See more code actions. gcloud compute os-login ssh-keys add --key-file=/home/user/.ssh/id_rsa.pub --ttl=1y To add a key not stored in a file, run: gcloud compute os-login ssh-keys add --key='ssh-rsa AAAAB3NzaC1yc2EAAA…MTg+InRG47+/O4/uWEOy6gIQEF user@example.com' REQUIRED FLAGS Exactly one of these must be specified: --key = KEY The SSH public key to add to the OS Login Profile. --key-file = KEY_FILE The path to a file containing an SSH public key to add to the OS Login Profile. OPTIONAL FLAGS --ttl = TTL https://cloud.google.com/sdk/gcloud/reference/compute/os-login/ssh-keys/add Page 1 of 2 The amount of time before the SSH key expires. For example, specifying 30m 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. GCLOUD WIDE FLAGS These flags are available to all commands: --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. NOTES These variants are also available: gcloud alpha compute os-login ssh-keys add gcloud beta compute os-login ssh-keys add 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 2025-05-07 UTC. Source: https://cloud.google.com/sdk/gcloud/reference/compute/os-login/ssh-keys/add https://cloud.google.com/sdk/gcloud/reference/compute/os-login/ssh-keys/add Page 2 of 2