Alternative guide – encrypt mail

Using GnuPG (GPG) in the terminal to send and receive messages and encrypted files involves several steps. Here is a basic guide to help you get started.

  1. Install GnuPG

Make sure you have GnuPG installed on your system. You can check by running:

gpg --version

If it’s not installed, you can install it using your package manager. For example, on Debian-based systems:

sudo apt-get install gnupg

or arch-based systems:

sudo pacman -S gnupg

  1. Generate a Key Pair

If you haven’t already created a GPG key pair, you can do so with:

gpg --full-generate-key

Follow the prompts to select the key type, key size, expiration date, and to enter your user ID and passphrase.

  1. Export Your Public Key

To share your public key with others, you can export it:

gpg --export -a "Your Name" > publickey.asc

Replace “Your Name” with the name or email associated with your key.

  1. Import a Public Key

To send an encrypted message to someone, you need their public key. If you receive a public key file (e.g., friendkey.asc), import it using:

gpg --import friendkey.asc

  1. Encrypt a Message

To encrypt a message for a recipient, you can use:

echo "Your secret message" | gpg --encrypt --armor -r "Recipient Name" > message.asc

Replace “Recipient Name” with the name or email associated with the recipient’s public key. The –armor option creates an ASCII-armored output.

  1. Decrypt a Message

To decrypt a message you received, use:

gpg --decrypt message.asc

You will be prompted for your passphrase if the message is encrypted with your public key.

  1. Encrypt a File

To encrypt a file, use:

gpg --encrypt -r "Recipient Name" file.txt

This will create an encrypted file named file.txt.gpg.

  1. Decrypt a File

To decrypt an encrypted file, use:

gpg --decrypt file.txt.gpg > decrypted_file.txt
  1. Sending Encrypted Files

You can send the encrypted file (file.txt.gpg) via email or any other file transfer method. Only the recipient with the corresponding private key can decrypt it.

  1. Additional Commands List Keys: To see the keys you have, use:
gpg --list-keys

Delete a Key: To delete a key, use:

gpg --delete-key "Key Name"

Conclusion

This guide provides a basic overview of sending and receiving messages and files using GnuPG in the terminal. For more advanced features and options, refer to the GnuPG documentation or use man gpg in the terminal for more details.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *