Rachit Arora

PGP tutorial

Jan 13, 2024

Exporting your key

gpg --armor --export WhatEverNameYouWant!


gpg --armor --output myPubKey.asc --export WhatEverNameYouWant

gpg --armor -export WhatEverNameYouWant > myPubKey.asc


gpg --armor --export-secret-keys WhatEverNameYouWant

To export to a file, use either the “–output” or the “>” character methods outlined above. As a reminder, do not EVER share your private key with anyone. The only time you should be exporting your private key is when creating a back up.

Importing a Key

gpg --import path/to/pubkey.asc

where pubkey.asc is the file where you saved the public key you want to import. Here’s the output you should receive:

gpg: key (Expunged): public key "Agora One" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)


Fileless method

The Fileless Method To import a key directly, without the use of a file, you can use either the “cat” command, or “echo” along with a pipe character “|” Using “cat”

cat  "" | gpg --import
gpg: key 0B701872: public key "Mun Mun Mun " imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

Signatures and Verification

There are three common scenarios for the use of clearsigning:

Clearsigning

gpg -a --export key.asc | gpg --clearsign
cat <<END | gpg --clearsign

Verifying Signatures

Good signature
cat <<END | gpg --verify
Bad signature
cat <<END | gpg --verify

Have any questions

Do you have any questions? Feel free to reach out to me on twitter or on LinkedIn.