Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vecerek/037109c499f386d5e6e57308ca5f8717 to your computer and use it in GitHub Desktop.
Save vecerek/037109c499f386d5e6e57308ca5f8717 to your computer and use it in GitHub Desktop.
# SENDER

gpg --import recipient-pubkey.gpg # import key to your keyring

# gpg: key ______: public key "Your friend's name <[email protected]>" imported
# gpg: Total number processed: 1
# gpg:               imported: 1

gpg --output myfile.txt.gpg --encrypt --recipient [email protected]  myfile.txt #encrypt message

# Output will bee: myfile.txt.gpg

# (OPTIONAL STEP)
shasum -a 256 myfile.txt | awk '{print $1}' >myfile.txt.sha256sum # generate sha sum for integrity check
gpg --output myfile.txt.sha256sum.sig --sign myfile.txt.sha256sum # sign the file with your private key

# RECIPIENT

gpg --output myfile.txt --decrypt myfile.txt.gpg # Decrypt
gpg --verify myfile.txt.sha256sum.sig # verify the signature

# gpg: Signature made Tue 26 Sep 2017 09:10:22 PM SGT
# gpg:                using RSA key ID 741A869EBC910BE2
# gpg: Good signature from "Sender's name <[email protected]>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 85AF 5410 058C FE1D 76DA  986F 910C B963 468A 0F16

# list the public keys in your GPG keyring alongside their fingerprint
# check if the ID and fingerprint from the previous output matches the recipient's id and fingerprint from your keyring
gpg --list-keys --keyid-format LONG --fingerprint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment