LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

glab-ssh-key

Manage SSH keys on a GitLab account

TLDR

List your SSH keys
$ glab ssh-key list
copy
Include numeric IDs
$ glab ssh-key list --show-id
copy
Add a public key file
$ glab ssh-key add [path/to/key.pub] --title "laptop"
copy
Add a key from standard input
$ glab ssh-key add --title "laptop"
copy
Set usage and an expiration date
$ glab ssh-key add [path/to/key.pub] --title "signing" --usage-type signing --expires-at 2027-01-01
copy
Show one key
$ glab ssh-key get [key_id]
copy
Delete one key
$ glab ssh-key delete [key_id]
copy

SYNOPSIS

glab ssh-key command [flags]

DESCRIPTION

glab ssh-key adds, lists, prints, and deletes SSH keys on the GitLab account that glab auth is logged in as. GitLab uses those keys for Git over SSH and, depending on the usage type, for signed commits.GitLab rejects a key whose fingerprint is already registered, including an expired key. --replace removes that key and uploads the new title, usage, and expiration.

PARAMETERS

-t, --title title

Title stored with a new key.
-u, --usage-type type
`auth`, `signing`, or the combined scope below. The combined scope is the default.
$ auth_and_signing
copy
Combined authentication and signing scope.
-e, --expires-at date
Expiration time in ISO 8601, such as `YYYY-MM-DDTHH:MM:SSZ`.
--replace
Replace a key that already has this fingerprint.
--show-id
On list, print key IDs.
-F, --output text|json
Output format for list and get.

SUBCOMMANDS

list

List SSH keys for the authenticated user: title, key, usage type, and creation date. --show-id adds the numeric ID that get and delete accept.
add [key-file]
Upload a public key. --title is required. With no file, the key is read from standard input. --usage-type is `auth`, `signing`, or both (the default). --expires-at takes an ISO 8601 date. --replace deletes an existing key with the same SHA256 fingerprint, then adds this one.
get [key-id]
Print one public key. With no ID, pick a key interactively. --output json prints the full key object.
delete [key-id]
Delete one key. With no ID, pick a key interactively. The deletion is permanent.

CAVEATS

delete cannot be undone. add stores the public key on GitLab; pass the `.pub` file, not the private key. An expired key still occupies its fingerprint until it is replaced or deleted.

SEE ALSO

RESOURCES

Copied to clipboard
Kai