Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Setting up GPG signature on Mac OS X with Xcode
/usr/local/bin/gpg --batch --passphrase-file ~/.gnupg/key.txt --no-tty "$@"
brew install gpg
# Generating and exporting
gpg --gen-key
gpg --armor --export <email> > ~/.backups/gpg_git_public.key
gpg --armor --export-secret-key <email> > ~/.backups/gpg_git_private.key
chmod 600 ~/.backups/gpg_git_public.key
chomd 600 ~/.backups/gpg_git_private.key
# Importing
gpg --armor --import ~/.backups/gpg_git_private.key
gpg --list-secret-keys
# Copy the 8-digit id of the key (in the `sec` section)
git config --global user.signingkey <8-digit key id>
git config --global commit.gpgsign true
vim ~/.gnupg/key.txt
# Put the passpharse for the GPG key to the first line of the file
chmod 600 ~/.gnupg/key.txt
vim /usr/local/bin/gpg-with-key
# Add lines from the gpg-with-key file of this gist
chmod 755 /usr/local/bin/gpg-with-key
git config --global gpg.program "/usr/local/bin/gpg-with-key"

This comment has been minimized.

Copy link

cdalvaro commented Oct 16, 2018

If you also want to prevent gpg from asking you for the passphrase when using git with the command line, you should add --pinentry-mode=loopback to the gpg-with-key file

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.