GPG Key Configuration
Signing Git with GPG using Keybase
This tutorial was originally writen by Stephen Rees-Carter
We suggest using this method of GPG key setup to reduce the amount of keys you need to maintain when working on your devices, however it's not perfect for everyone. This tutorial assumes that you are working from a private machine.
Prerequisities
- Keybase installed
- GPG Key configured within Keybase
- GPG installed on your device (Windows | Linux | macOS)
Update the GPG Key
First, export your public and private keys from Keybase using the
keybase pgpcommand:keybase pgp export --outfile keybase-public.key
keybase pgp export --secret --outfile keybase-private.keyDuring the export process, Keybase will ask for your account password and prompt to set a new password for the private key file.
Next, you need to import the keys into GPG using the
gpgcommand:gpg --allow-secret-key-import --import keybase-private.key
gpg --import keybase-public.keyThe import process will ask for the password you just assigned to your private key, for obvious reasons.
Now that you’ve imported the key into GPG, you need to modify the key to include your email address. This is done by invoking the
gpg --edit-keycommand, with a unique identifier for your key. I found using the<username>@keybase.ioaddress worked nicely.gpg --edit-key < username > @keybase.ioThis command will get you into the
gpg>prompt, and from there you need to run theadduidcommand. It will prompt for yourReal nameandEmail address(feel free to leaveCommentempty). Once you’ve provided your name and email, confirm using theOand thensaveto close thegpg>prompt.Using
gpg --edit-key <key>and selecting thetrustoption. I suggest using trust level5 = I trust ultimately, since it is your own key. After applying the change, usesaveto close the prompt.Once that’s done, you can push your updated key back into Keybase.
keybase pgp updateAdd key to Github (follow this tutorial)
Setup git signing on commits Use the
git config user.signingkeyoption to specify the Key ID for git to use. You can get this from the GitHub GPG keys page if you’re unsure what it is. You can also require Git to sign all commits with thecommit.gpgsignoption.git config --global user.signingkey <Key ID>
git config --global commit.gpgsign true