Install
brew install gnupg
Generate
gpg --full-generate-key

gpg --list-secret-keys
Generate Problem
$ gpg --full-generate-key
gpg: Sorry, no terminal at all requested - can't get input

Comment out no-tty in ~/.gnupg/gpg.conf

Add to git
gpg --armor --export 51ADF7101CA64B2508AE29EEC279555531A1DD62
Set .gitconfig
git config user.email zeyanlin@outlook.com
git config user.name Ricky
git config user.signingkey 51ADF7101CA64B2508AE29EEC279555531A1DD62
git config commit.gpgsign true
Delete key
gpg --delete-secret-keys 51ADF7101CA64B2508AE29EEC279555531A1DD62
Backup key
# https://www.jwillikers.com/backup-and-restore-a-gpg-key
gpg --list-secret-keys --keyid-format LONG

# Export key as a file, replace email-address and Enter the private key’s passphrase
gpg -o private.gpg --export-options backup --export-secret-keys rickylin@cloud-miner.net

# Restore key and enter the private key’s passphrase
gpg --import-options restore --import private.gpg
If GPG not work
echo 'export GPG_TTY=$(tty)' >> ~/.zshrc
gpgconf –kill gpg-agent
exec $SHELL
Encrypt file
# Encrypt file
gpg --symmetric --cipher-algo aes256 archive_file.tar

# Decrypt file
gpg --output archive_file.tar --decrypt archive_file.tar.gpg