gh-repo-deploy-key-add(1)

gh-repo-deploy-key-add1

Add a deploy key to a github repository

Usage

gh repo deploy-key add <key-file> [flags]

Overview

Add a deploy key to a GitHub repository.

Note that any key added by gh will be associated with the current authentication token. If you de-authorize the GitHub CLI app or authentication token from your account, any deploy keys added by GitHub CLI will be removed as well.

Options

-w, --allow-write

Allow write access for the key

-t, --title <string>

Title of the new key

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>

Select another repository using the [HOST/]OWNER/REPO format

Exit status

0: Successful execution

1: Error

2: Command canceled

4: Authentication required

NOTE: Specific commands may have additional exit codes. Refer to the command's help for more information.

Examples

# Generate a passwordless SSH key and add it as a deploy key to a repository
$ ssh-keygen -t ed25519 -C "my description" -N "" -f ~/.ssh/gh-test
$ gh repo deploy-key add ~/.ssh/gh-test.pub

Releases

3 releases since Debian 12 (Bookworm); the text changed 2 times.

  1. 12
  2. 13
  3. Arch

From github-cli 2.103.3-1 in Arch Linux 2026-11-07. Parsed by carta from the page's man source.