Skip to content

Instantly share code, notes, and snippets.

@evaldasg
Created October 2, 2023 17:16
Show Gist options
  • Save evaldasg/c9e2f0adf241e0895b3a1ac7acdfabbc to your computer and use it in GitHub Desktop.
Save evaldasg/c9e2f0adf241e0895b3a1ac7acdfabbc to your computer and use it in GitHub Desktop.
GPG Setup

https://docs.github.com/en/authentication/managing-commit-signature-verification/generating-a-new-gpg-key Git GPG Setup for macOS Packages Install gnupg brew install gpg Install passphrase entry dialogs brew install pinentry-mac Generate a key Follow instructions, select default via Enter if unsure.

gpg --full-generate-key Identify your key: gpg --list-secret-keys --keyid-format=long Your is in “sec” part after slash, eg: sec ed25519/HERE 2021-12-07 [SC]

NOTE: M1 macs or freshly installed brew Check where brew is located itself:

which brew Substitute all /usr/local/bin locations in the paths below to: /opt/homebrew/bin.

Set git settings git config --global user.signingkey git config --global commit.gpgsign true git config --global gpg.program /usr/local/bin/gpg Additional config if [ -r ~/.zshrc ]; then echo 'export GPG_TTY=$(tty)' >> ~/.zshrc;
else echo 'export GPG_TTY=$(tty)' >> ~/.zprofile; fi echo "pinentry-program /usr/local/bin/pinentry-mac" > ~/.gnupg/gpg-agent.conf Restart gpg service gpgconf --kill gpg-agent Add your key to GitHub Output your public key: gpg --armor --export Add it to GitHub here: https://github.com/settings/gpg/new

Second Machine If you are moving your gpg folder (~/.gnupg) to another machine, make sure to correct permissions afterwards:

chown -R $(whoami) ~/.gnupg/ chmod 600 ~/.gnupg/* chmod 700 ~/.gnupg NOTE: M1 macs or freshly installed brew Some tools may be hardcoded to look only in one location, make a symlink:

sudo ln -s /opt/homebrew/bin/gpg /usr/local/bin

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