Skip to content

Instantly share code, notes, and snippets.

@aleksbelic
Last active September 1, 2018 17:40
Show Gist options
  • Save aleksbelic/c476126d8c477a5de1b96ac005fafa15 to your computer and use it in GitHub Desktop.
Save aleksbelic/c476126d8c477a5de1b96ac005fafa15 to your computer and use it in GitHub Desktop.
GPG commands overview
To list all public keys stored in your keyring:
gpg --list-keys
To list all private keys stored in your keyring:
gpg --list-secret-keys
To generate a new key(pair):
gpg --gen-key
To generate a revocation certificate:
use gpg --gen-revoke
To import a public key or a private key, use the --import switch:
gpg --import key.pgp
To export a public key, use the --export switch:
gpg --export KEY_ID
To export a private key, use the --export-secret-keys switch:
gpg --export-secret-keys KEY_ID
To operate in ASCII mode, use the --armor (or -a) switch.
To encrypt a file in GPG, use the --encrypt (or -e) switch. Note: you have to specify the recipient as well so GPG knows which public key to use. To do that, use the --recipient (or -r) switch:
gpg --encrypt --recipient RECIPIENTS_EMAIL FILE_NAME
or
gpg -e -r RECIPIENTS_EMAIL FILE_NAME
To sign files, use the --sign (or -s) switch:
gpg -s FILE_NAME
or to encrypt it as well:
gpg -e -s -r RECIPIENTS_EMAIL FILE_NAME
To decrypt files you can use the --decrypt (or -d) switch, or no switch at all - it’s the default option:
gpg FILE_NAME
or
gpg -d FILE_NAME
To find the fingerprint of a key, use the --fingerprint option.
To verify a file, simply run the following command in the directory with both files: file you want to verify and the file with the signature:
gpg --verify filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment