Skip to content

Instantly share code, notes, and snippets.

@kreig303
Last active February 22, 2020 15:34
Show Gist options
  • Save kreig303/96314bb8801779d08e5c53fe6fb05f16 to your computer and use it in GitHub Desktop.
Save kreig303/96314bb8801779d08e5c53fe6fb05f16 to your computer and use it in GitHub Desktop.
set up zsh to use gpg to sign commits for github
# Install GnuPG
% brew install gnupg
% gpg --full-generate-key
# RSA and DSA/4096 bytes/Never expires
# enter name
# noreply from emails settings in gh if anon commits, otherwise primary email
# empty comment
# secure passphrase
# bang on keyboard to randomize key
# output will be:
# -------------------------------------
# sec   rsa4096/AAAABBBBCCCCDDDD 2020-01-01 [SC]
#      096D86C5034E2DB9543C40BFB53551D684FCD7C4
# uid                 [ultimate] Your Name <[email protected]>
# ssb   rsa4096/EEEEFFFF00001111 2020-01-01 [E]
# export command with key from 'sec' line after 'rsa4096/'
% gpg --armor --export AAAABBBBCCCCDDDD
# -----BEGIN PGP PUBLIC KEY BLOCK-----
# husxjijsijJIJ762378 etc.
# -----END PGP PUBLIC KEY BLOCK-----
# copy all including the ----- tags
# go to settings ssh and gpg keys in gh
# paste into a new gpg key there!
# return to terminal
% git config --global commit.gpgsign true
% git config --global user.signingkey AAAABBBBCCCCDDDD # same thing as used in above gpg --export statement
% echo 'export GPG_TTY=$(tty)' >> ~/.zprofile # add export to ~/.zprofile
% . ~/.zprofile # reload profile
# now go and change some stuff in a repo. when you commit...
% git commit -S -m 'Change Message.' # note using new flag -S which indicates "Secure"
# go to gh commits for that branch and see new "Verified" box appear next to your username for that commit in the commit list!!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment