Skip to content

Instantly share code, notes, and snippets.

@zainfathoni
Forked from r17x/gpggithub.md
Created December 16, 2018 11:13
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 zainfathoni/df18ca8ac64aa613203015c021cbe894 to your computer and use it in GitHub Desktop.
Save zainfathoni/df18ca8ac64aa613203015c021cbe894 to your computer and use it in GitHub Desktop.
GPG Signing Key For Github
  • Setup Basic
$ git config --global user.name "name"
$ git config --global user.email "email"

# mac
$ brew install gpg
# brew install gpg2 

$ git config --global gpg.program gpg

$ gpg full-generate-key
# input your username
# input your email
# select maximum or size your gpg key 
# recomended 2048 or 4086
$ gpg --list-secret-keys --keyid-format LONG
///// Output example copy XXXXXXXXXXXX
/Users/rin/.gnupg/pubring.kbx
-----------------------------
sec   rsa4096/XXXXXXXXXXXXX 2018-12-16 [SC]
      x0x0x0x0x0x0xx00x0xx00x0x0x0x0x0x0x0x0
uid            xyxyxyxyxyxyxyxyx 2018-12-16 [E]

$ git config --global user.signingkey XXXXXXXXXXX
$ gpg --armor --export xxxxxxxxxxxxx
# example output &  copy all output
-----BEGIN PGP PUBLIC KEY BLOCK-----
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-----END PGP PUBLIC KEY BLOCK-----
# paste in your github.com -> settings SSH & GPG
# for test 
$ echo "test" | gpg --clearsign
# if Output 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

test
gpg: signing failed: Inappropriate ioctl for device
gpg: [stdin]: clear-sign failed: Inappropriate ioctl for device
# 
$  echo "export GPG_TTY=$(tty)" >> .zshrc # .bashrc or .profile 
# finally go to directory project 
# git add 
# git commit -S -m "Secure Committing"
# git push origin master
# check your github commit as verified (y) :D 
# Happy All The Time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment