How to create your GPG key, import it and sign your commits.
You can easily generate your GPG keys using the gpg bundle. It'll all depend on the type of system you're working on. For MacOS, download GPG Suite and generate your keys following the steps. Choose at least 4096 bytes and RSA.
After that, run the following command and copy the fingerprint of your public key.
gpg --list-secret-keys --keyid-format=long
Then, add it to your .gitconfig
global:
git config --global user.signingKey {fingerprint}
To sign all your commits automatically (and not rely on -S
):
git config --global commit.gpgsign true
- Search for keys from other people:
gpg --search-keys <email>
- Get your complete public key:
gpg --armor --export <fingerprint>
- Get GPG key from another GitHub user:
curl https://api.github.com/users/Guilospanck/gpg_keys | jq ".[0].raw_key" -r | gpg --import
- Decrypt file
gpg --decrypt hello.go.gpg > hello.go