<< All Posts
How to encrypt and decrypt a file using pgp and some public key


Hi,

Do you need to send some encrypted file to anyone that you know that has a public pgp key? If you aren’t sure if this person has or not a public key, you can search for the last valid key here:

https://pgp.mit.edu/

pgp -e -r [email protected] your-file-to-encrypt.txt

pgp will create a new encrypted file in the same directory with the extension .pgp concatenated.

your-file-to-encrypt.txt.pgp

Okay! Encrypted!
Now, I’m gonna teach you how to make the reverse way, yeah, how to decrypt this file with your private key and your master password. If the person lost the private key, its impossible to open this file. If its lost, the person must to create a new private and public key again.

Make sure that you have your private key imported to your local gpg. To see if your private key is there, just type:

pgp --list-keys

And than, you can decrypt your file using this:

pgp --output file-decrypted.txt --decrypt your-file-to-encrypt.txt.pgp

You’ll gonna be asked about the password. If you don’t remember, just breath and try again. :)

Sources:



<< All Posts

rodolfo.io

🇧🇷 🇨🇦
Runs on OpenBSD 🐡