How to encrypt and decrypt a file using pgp and some public key
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:
pgp -e -r firstname.lastname@example.org your-file-to-encrypt.txt
pgp will create a new encrypted file in the same directory with the extension .pgp concatenated.
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:
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.