Sign commits with GPG keys

less than 1 minute read

Configure the environment

Install GPG2

sudo apt -y install gnupg2 gnupg-agent pinentry-gnome3 

Verify installation

gpgconf

Expected output is like the following:

gpg:OpenPGP:/usr/bin/gpg 
gpg-agent:Private Keys:/usr/bin/gpg-agent 
scdaemon:Smartcards:/usr/lib/gnupg/scdaemon 
gpgsm:S/MIME:/usr/bin/gpgsm 
dirmngr:Network:/usr/bin/dirmngr 

Generate GPG keys

gpg --full-generate-key

Answer the questions that the tool will return. The recommended choices are:

  • Type of the key: RSA
  • Key size: at least 4096 bits
  • Key validity period: 1 year

Check imported keys

gpg --list-keys

Configure IntelliJ IDE

Settings Version Control Git Configure GPG Key

Configure GPG Key

Commits are signed

Export the keypair to a file

Use the same email address that you used for generating the key pair:

gpg --export -a "email@address.com" > public.key

Updated: