Skip to content

Instantly share code, notes, and snippets.

@koconder
Last active June 7, 2022 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koconder/2799127c5d93dac6fe7a7b540b531a3a to your computer and use it in GitHub Desktop.
Save koconder/2799127c5d93dac6fe7a7b540b531a3a to your computer and use it in GitHub Desktop.
Keybase GPG and Git Setup on Mac OS

Setup Tools

brew install gpg
brew install pinentry-mac
brew install --cask gpg-suite
brew install --cask keybase

Export Keys

Export your public key:

keybase pgp export > keybase-public.key

Export your private key:

keybase pgp export --secret > keybase-private.key

Add Keys to GPG

Let's import and edit:

gpg --allow-secret-key-import --import keybase-private.key
gpg --import keybase-public.key
gpg --edit-key MYEMAIL@DOMAIN.COM

Sync with Keybase

Jump onto GPG Keybase tool and edit the Keybase secret and add the additional emails under User ID's in details. Out of the gnupg shell, update your keybase account with the new public key:

keybase pgp update

Setup Git

Check your new public key and export to your clipboard:

keybase pgp export | pbcopy

Update your github or whatever accounts you need to recognize the new email as "verified" If you see any emails that are "unverified" please be sure to go to your email settings and verify those emails.

Following the instructions on Git to add the GPG keys (https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key):

gpg --list-secret-keys --keyid-format=long

Add key to Git and replace <<KEY>> with Key Id

git config --global user.signingkey <<KEY>>
git config --global gpg.program $(which gpg)
git config --global commit.gpgsign true

Add shell script for the GPG key

if [ -r ~/.zshrc ]; then echo 'export GPG_TTY=$(tty)' >> ~/.zshrc; \
  else echo 'export GPG_TTY=$(tty)' >> ~/.zprofile; fi

Setup Pinentry

echo "pinentry-program $(which pinentry-mac)" >> ~/.gnupg/gpg-agent.conf
gpgconf --kill gpg-agent
killall gpg-agent
pinentry-program /usr/local/bin/pinentry-mac

Test GPG is working

echo 'it works' | gpg --clearsign

Setup IDEs

Open VSCode, go to Preferences > Settings, and search for git.enableCommitSigning. Turn this setting on, and you’re good to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment