Skip to content

Instantly share code, notes, and snippets.

@hugefiver
Created October 29, 2021 07:10
Show Gist options
  • Save hugefiver/5ea028a5f6546934e8874bfa1b27c021 to your computer and use it in GitHub Desktop.
Save hugefiver/5ea028a5f6546934e8874bfa1b27c021 to your computer and use it in GitHub Desktop.
gpg knowledge
# generate a key pair
gpg --gen-key
# , with choices
gpg --full-gen-key # or `--full-generate-key`
# , need more choice, such as ecc key pair
gpg --full-gen-key --expert
# list keys
gpg --list-keys # ,or shorter `-k`
# , or secret key
gpg --list-secret-keys # or shorter `-K`
# , if you need key id
gpg -k --keyid-format SHORT # or `LONG` for long -- p.s. maybe lowercase is also fine
# list signatures
gpg --list-signatures
# check signatures
gpg --check-signatures
# import key
gpg --import # import from stdin
gpg --import <key.gpg> # import from file
# export pub key
gpg --export <key id|name|email> # [-o <key.gpg>]
gpg --export <key id|name|email> -a -o <key.asc> # `-a` mains readable ascii, as also `--armor`
# sign a file
gpg -s -r <key id|name|email> <file> # `-s` as `--sign`
gpg --clear-sign -r <key id|name|email> -o <file.gpg> <file> # output as ascii text file
# , with a standalone signature file
gpg --detach-sign -r <key id|name|email> <file>
gpg -b -r <key id|name|email> <file>
# verify a signature
gpg --verify <file.gpg>
# encrypt
gpg -e -r <key id|name|email> # no file and `-o` specialed means input from stdin and output to stdout
gpg --encrypt -r <key id|name|email> -o <file.gpg> <file>
# , special compress and encrypt algo
# encrypt algo: 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, ...
# compress algo: NONE, ZIP, ZLIB, BZIP2
# `-z` as `--compress-level` can be used
gpg -e --cipher-algo AES256 --compress-algo none
# decrypt
gpg -d
gpg --decrypt
# symmetric encrypt
gpg -c
gpg --symmetric
# , password from shell command
gpg -c --batch --yes --passphrase <passwd>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment