Git and SSH

Sign your commits with your SSH key

Get the green "Verified" badge on GitHub, using the SSH key you already have.

  1. Tell Git to sign every commit with your SSH key
    Terminal
    git config --global gpg.format ssh
    git config --global user.signingkey ~/.ssh/id_ed25519.pub
    git config --global commit.gpgsign true

    No SSH key yet? Create one first with the SSH key page.

  2. Copy the key and add it on GitHub as a Signing Key
    Terminal
    pbcopy < ~/.ssh/id_ed25519.pub
    open https://github.com/settings/ssh/new

    Set "Key type" to Signing Key. It's separate from the one you use to push.

Check it worked

  1. Check signing is switched on
    Terminal
    git config --global --get commit.gpgsign

    You should see true. Your next pushed commit shows "Verified" on GitHub.

Undo it
  1. Stop signing commits
    Terminal
    git config --global --unset commit.gpgsign
  1. Tell Git to sign every commit with your SSH key
    Terminal · Ubuntu / Debian
    git config --global gpg.format ssh
    git config --global user.signingkey ~/.ssh/id_ed25519.pub
    git config --global commit.gpgsign true

    No SSH key yet? Create one first with the SSH key page.

  2. Show the key, then add it on GitHub as a Signing Key
    Terminal · Ubuntu / Debian
    cat ~/.ssh/id_ed25519.pub
    xdg-open https://github.com/settings/ssh/new

    Set "Key type" to Signing Key. It's separate from the one you use to push.

Check it worked

  1. Check signing is switched on
    Terminal · Ubuntu / Debian
    git config --global --get commit.gpgsign

    You should see true. Your next pushed commit shows "Verified" on GitHub.

Undo it
  1. Stop signing commits
    Terminal · Ubuntu / Debian
    git config --global --unset commit.gpgsign
  1. Tell Git to sign every commit with your SSH key
    PowerShell
    git config --global gpg.format ssh
    git config --global user.signingkey "$env:USERPROFILE\.ssh\id_ed25519.pub"
    git config --global commit.gpgsign true

    No SSH key yet? Create one first with the SSH key page.

  2. Copy the key and add it on GitHub as a Signing Key
    PowerShell
    Get-Content "$env:USERPROFILE\.ssh\id_ed25519.pub" | Set-Clipboard
    Start-Process "https://github.com/settings/ssh/new"

    Set "Key type" to Signing Key. It's separate from the one you use to push.

Check it worked

  1. Check signing is switched on
    PowerShell
    git config --global --get commit.gpgsign

    You should see true. Your next pushed commit shows "Verified" on GitHub.

Undo it
  1. Stop signing commits
    PowerShell
    git config --global --unset commit.gpgsign