Skip to content

Instantly share code, notes, and snippets.

@atlance
Forked from ankurk91/github_gpg_key.md
Created February 24, 2023 14:29
Show Gist options
  • Select an option

  • Save atlance/ace7193f21bddaa5b15e8d16e7609b98 to your computer and use it in GitHub Desktop.

Select an option

Save atlance/ace7193f21bddaa5b15e8d16e7609b98 to your computer and use it in GitHub Desktop.
Signing git commits using GPG (Ubuntu/Mac)

Github : Signing commits using GPG (Ubuntu)

  • You have an account on Github already ? If not ceate one.
  • Install required tools
# Ubuntu
sudo apt-get install gpa seahorse
# Mac
brew install gpg
  • Generate a new gpg key
gpg --gen-key
  • Answer the question asked

Note: When asked to enter your email address, ensure that you enter the verified email address for your GitHub account.

  • List generated key
gpg --list-secret-keys --keyid-format LONG
  • Above command should return like this
/home/username/.gnupg/secring.gpg
-------------------------------
sec   4096R/<COPY_THIS_KEY> 2016-08-11 [expires: 2018-08-11]
uid                          User Name <[email protected]>
ssb   4096R/62E5B29EEA7145E 2016-08-11

  • Note down your key COPY_THIS_KEY from above
  • Export this key
gpg --armor --export <PASTE_KEY_HERE> > gpg-key.txt
  • Above command will create a new txt file gpg-key.txt

  • Tell git to auto sign your future commits

git config --global user.signingkey <KEY_HERE>
git config --global commit.gpgsign true
git config --global tag.gpgsign true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment