gcloud alpha compute os-login ssh-keys add - add an SSH public key to an OS Login profile
gcloud alpha compute os-login ssh-keys add (--key=KEY | --key-file=KEY_FILE) [--ttl=TTL] [GCLOUD_WIDE_FLAG ...]
(ALPHA) gcloud alpha 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.
To add the key in /home/user/.ssh/id_rsa.pub to your OS Login profile, run:
$ gcloud alpha 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:
$ gcloud alpha 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 alpha compute os-login ssh-keys add \ --key='ssh-rsa AAAAB3NzaC1yc2EAAA...MTg+InRG47+/O4/uWEOy6gIQEF user@example.com'
- 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.
- --ttl=TTL
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.
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.
This command is currently in alpha and might change without notice. If this command fails with API permission errors despite specifying the correct project, you might be trying to access an API with an invitation-only early access allowlist. These variants are also available:
$ gcloud compute os-login ssh-keys add
$ gcloud beta compute os-login ssh-keys add