brew install gnupg
brew install pinentry-mac
gpg --full-generate-key
gpg --list-keys
gpg --list-keys and node the identifier of the key you want to removegpg --delete-secret-key <identifier>gpg --delete-key <identifier>gpg --export --armor --output <filename>.pub <email>
This command exports your identify (public key) to the file that you define
gpg --import <filename>.pub
Signing person A’s public key with your private key demonstrates to person B that you trust person A. If person B trusts you (has your identity added) they can verify that you trust person A and can choose to trust person A by association.
gpg --sign-key <email>
Note: the email address is the address associated with they key you are signing
Typically, after you have signed a key you would then export that key and send it to a friend so they have the identity of and can trust the identity you have signed
https://pgp.mit.edu/ is a popular key server for exchanging and looking up identities. This site can be visited in your browser allowing you to manually paste your key & look up other’s keys or you can interface with it directly through the GPG command line tool.
gpg --send-keys --keyserver pgp.mit.edu <key-id>
gpg --keyserver pgp.mit.edu --search-keys <search-parameters>
Note: Search parameters can be the name, email, or other details associated with an identity
Signing a message allows a recipient to verify the author of the message assuming that they have the public key identity of the author added to their identity list.
echo "Hello World!" > message.txtgpg --output message.sig --sign message.txtThis will create a new file containing the original message and the signature to validate it which can be verified with your public key
gpg --output decrypted.txt --decrypt message.sig
This command will output the identity and validity of the signed message to the console and write the contents/message to the file decrypted.txt
gpg --encrypt --sign --armor -r <recipient@example.com> <message.txt>
Note: This command will sign the message with your private key as well as encrypt the message with the recipient’s public key so that only the the recipient can decrypt it using their private key and they can verify you as the author using your public key identity.
gpg --decrypt --output <decrypted-message> <encrypted-file>.asc
pinentry-mac (for storing GPG password in keychain on Mac)
brew install pinentry-mac
mkdir ~/.gnupg
echo "use-agent" >> ~/.gnupg/gpg.conf
echo "pinentry-program /usr/local/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf
echo "export GPG_TTY=$(tty)" >> ~/.zshrc
source ~/.zshrc
Use /opt/homebrew for Apple Silicon; use /usr/local for x86
gpg --full-generate-key
gpg --list-keys --keyid-format LONG
The ID is listed on the first line after the algorithm
git config --global user.signingkey KEY-ID
git config --global commit.gpgsign true
gpg --armor --export KEY-ID
Add the output of this to GitHub