GPG Encryption Options Explained | Generated by AI
GPG Options Explanation
The gpg command (GNU Privacy Guard) is a tool for encryption, decryption, and key management. The options you mentioned are commonly used together for encrypting files to a specific recipient. Here’s what each one means:
-
--homedir <directory>: Specifies the GnuPG home directory (default is~/.gnupg). This is where GPG stores keyrings, configuration files, and other data. It overrides theGNUPGHOMEenvironment variable and is useful for isolating GPG operations to a custom location (e.g., for multiple profiles or security). It must be provided on the command line. -
-e(or--encrypt): Encrypts the input data using public-key cryptography. This is the primary mode for asymmetric encryption, where the data is encrypted with the recipient’s public key. It can be combined with other options like signing. -
-r <user-id>(or--recipient <user-id>): Specifies the recipient(s) for encryption. The<user-id>can be a key ID, email, or name associated with the public key. GPG will use the corresponding public key to encrypt the data. Multiple recipients can be listed for group encryption.
Example Usage
A common command combining these might look like:
gpg --homedir /path/to/custom/dir -e -r recipient@example.com inputfile.txt
This encrypts inputfile.txt for recipient@example.com using keys from /path/to/custom/dir, producing inputfile.txt.gpg.
For full details, run gpg --help or check the man page.
ArchWiki: GnuPG
GPG Cheat Sheet
GPG Command in Linux