- Install gpg and gpg-agent:
brew install gpg gpg-agent
- Generate a new key: run
gpg --gen-key
and follow the instructions - Write down the ID of the key. To do this, run
gpg --list-keys
. The output will look like this:
pub 4096R/E9468C9A 2016-04-20 [expires: 2016-07-19]
uid Andreas B. <[email protected]>
sub 4096R/D9035C79 2016-04-20 [expires: 2016-07-19]
In this case, the key is E9468C9A
. I'll refer to this as <id>
.
- Add
keyserver hkp://ipv4.pool.sks-keyservers.net
(optional; you may want to use another key server). Note: on MacOS, you may get aNo route to host
error if you don't choose an IPv4 server. - Send your key to a key server:
gpg --send-keys <id>
- Export the key for use on GitHub:
gpg --armor --export <id>
- Copy the block and paste it in your settings. For more information, see the official GitHub help page.
- Tell git to use this key:
git config --global user.signingkey <id>
git is now configured to sign tags or commits. There are multiple options now:
- To sign a commit, now run
git commit -S
. - To turn on commit signatures in a single repository, run
git config commit.gpgsign true
- To turn on commit signatures for all repositories, run
git config --global commit.gpgsign true
First you need to receive and trust your team members keys.
- Get their public key ID and fetch the key:
gpg --recv-key <id>
- You might have to trust this key. To find out more about trusting keys, read the corresponding manual page.
You need to receive and trust their key. Make sure you have verified it is their key before continuing!
- Sign their key. Run
gpg --sign-key --ask-cert-level <id>
. Answer the questions appropriately. - Export the new signature and encrypt it:
gpg -a --export <id> | gpg -a -e -r <id> -o "<id>_signed.asc"
- Send them the signature
- Delete their key from your keyring and reimport it:
gpg --delete-key <id>
followed bygpg --recv-key <id>
- Run
gpg -d <id>_signed.asc | gpg --import
to import it - Send the key to your default keyserver:
gpg --send-key <id>
Read https://www.phildev.net/pgp/gpgsigning.html.
- Edit your key. Run
gpg --edit-key <id>
. - Run
expire
and answer the questions - Select the first subkey using
key 1
and runexpire
again - Run
quit
to exit edit mode - Send your key to the keyserver:
gpg --send-keys <id>
.
Worked like a charm!