Essential Gnu Privacy Guard (GnuPG) Howto

less than 1 minute read

Published:

  • Creating a key through a full featured key generation dialog:
gpg --full-generate-key
  • Exporting public key for user [UID] in ASCII format and save it into publickey.asc:
gpg --export --armor [UID] > publickey.asc

Then, you should obtain something like this.

  • Importing public key from file [PUBLICKEY]:
gpg --import [PUBLICKEY]
  • List keys stored on you machine:
gpg --list-keys
  • Delete a secret key for user [UID]:
gpg --delete-secret-key [UID]
  • Delete a public key for user [UID]:
gpg --delete-key [UID]
  • Encrypt a file [FILE] for user [UIDRECIPIENT]:
gpg --recipient [UIDRECIPIENT] --encrypt [FILE]
  • Decrypt encrypted file [ENCRYPTEDFILE]:
gpg --decrypt [ENCRYPTEDFILE]
  • Encrypt and sign with signature of user [UIDSENDER] a file [FILE] for user [UIDRECIPIENT] in ASCII format:
gpg --local-user [UIDSENDER] --recipient [UIDRECIPIENT] --armor --sign --encrypt [FILE]

The signature is then checked when the obtained encrypted file [FILE].asc is decrypted.

In order to learn more about GnuPG, check the full manual and this extended Howto.

Moreover, if you are interested in cryptography, check my YouTube channel.