Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Signing git commits on github using keybase.io gpg key

Probably one of the easiest things you'll ever do with gpg

Install Keybase: https://keybase.io/download and Ensure the keybase cli is in your PATH

First get the public key

keybase pgp export | gpg --import

Next get the private key

keybase pgp export --secret | gpg --allow-secret-key --import

Verify progress:

gpg --list-secret-keys

Looks for something like

sec   4096R/C9D8E1A1 2017-02-16 [expires: 2033-02-12]
uid                  Sean Escriva <sean.escriva@gmail.com>
ssb   4096R/CC67212E 2017-02-16

The email address should match your Github email.

The C9D8E1A1 part is what you need next. By default this key is untrusted, so we'll fix that. To edit trust:

$ gpg --edit-key C9D8E1A1
gpg> trust
Please decide how far you trust this user to correctly verify other users' keys
(by looking at passports, checking fingerprints from different sources, etc.)

  1 = I don't know or won't say
  2 = I do NOT trust
  3 = I trust marginally
  4 = I trust fully
  5 = I trust ultimately
  m = back to the main menu

Your decision? 5
Do you really want to set this key to ultimate trust? (y/N) y

There are many levels of trust so choose what you're comfortable with.

$ git config --global user.signingkey C9D8E1A1
$ git config --global commit.gpgsign true

Now add it to your Github profile:

gpg --armor --export C9D8E1A1 | xclip

Add it to your GitHub profile under Settings/SSH and GPG keys. Replace xclip with clip or pbcopy for your current platform.

Use gpg agent if you don't want to enter the password every time.

View signed commits with : git log --show-signature -1

@FrenchBen

This comment has been minimized.

Copy link

commented Jul 26, 2018

I've had to use gpg --list-secret-keys --keyid-format LONG in order to get the proper gpg key for the --edit-key.

$ gpg --version
gpg (GnuPG) 2.2.7
libgcrypt 1.8.2
@tillkruss

This comment has been minimized.

Copy link

commented Aug 6, 2018

I got this error:

gpg: error building skey array: Inappropriate ioctl for device

And used this to import the secret key:

keybase pgp export --secret | gpg --batch --import
@xusy2k

This comment has been minimized.

Copy link

commented Aug 15, 2018

@tillkruss: taken from keybase/keybase-issues#2798

export GPG_TTY=$(tty)
@felipetio

This comment has been minimized.

Copy link

commented Jun 26, 2019

👍

@jufemaiz

This comment has been minimized.

Copy link

commented Jul 3, 2019

👍

@xphyr

This comment has been minimized.

Copy link

commented Aug 16, 2019

Thanks for the great writeup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.