Skip to content

Instantly share code, notes, and snippets.

@Manouchehri
Forked from bcomnes/git-gpg.md
Created November 17, 2016 06:05
Show Gist options
  • Save Manouchehri/034d12af0e5bd40812d3b74eebb13458 to your computer and use it in GitHub Desktop.
Save Manouchehri/034d12af0e5bd40812d3b74eebb13458 to your computer and use it in GitHub Desktop.
my version of gpg on the mac
  1. brew install gnupg21, pinentry-mac (this includes gpg-agent and pinentry)

  2. Generate a key: $ gpg --gen-key

  3. Take the defaults. Whatevs

  4. Tell gpg-agent to use pinentry-mac:

    $ vim ~/.gnupg/gpg-agent.conf 
    

    paste in

    # Connects gpg-agent to the OSX keychain via the brew-installed$
    # pinentry program from GPGtools. This is the OSX 'magic sauce',$
    # allowing the gpg key's passphrase to be stored in the login$
    # keychain, enabling automatic key signing.$
    pinentry-program /usr/local/bin/pinentry-mac
    
  5. Tell git about it: https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work

    $ gpg2 --list-keys
    /Users/schacon/.gnupg/pubring.gpg
    ---------------------------------
    pub   2048R/0A46826A 2014-06-04
    uid                  Scott Chacon (Git signing key) <schacon@gmail.com>
    sub   2048R/874529A9 2014-06-04
    
    $ git config --global user.signingkey 0A46826A
    
  6. Tell git that you are using gpg2 like a boss

    $ git config --global gpg.program gpg2
    
  7. Tell github about it https://help.github.com/articles/adding-a-new-gpg-key-to-your-github-account/

  8. Restart maybe or kill any running gpg-agents. They will not work.

  9. Sign your commits

    $ git commit -S -m 'yolo'
    
  10. Consider signing all your commits. In ~/.gitconfig:

    [commit]
    	gpgsign = true
    

    or

    $ git config --global commit.gpgsign true
    

You may also read:

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