I would like to make sure of one thing. When I am encrypting file, the only needed key to specify is --recipient, because I only need to specify key to encrypt (receiver key)? I don't need to specify name of my key. There is no point in specifying my key name, because encryption only uses only receiver key. Is that right?


There is no need for your own key when encrypting message to other recipients: only the recipient's public key is required.

There would be two scenarios though requiring to denote your own key: signing messages (which is an operation involving your own private key) and adding yourself as another recipient, consider encrypting mails also stored as encrypted copy in your sent mails folder. You wouldn't be able to read your own messages any more, if the only encryption key is the recipient's one. There is the --encrypt-to option in GnuPG, which allows you to define additional keys to encrypt for.


Yes. There is no need to provide another key than the one specified with --recipient.

To encrypt your file using GPG, you only need to specify one public key, with the option --recipient. You can take a look at the GNU Privacy Handbook - Encrypting and decrypting documents for more information:

To encrypt a document the option --encrypt is used. You must have the public keys of the intended recipients. The software expects the name of the document to encrypt as input or, if omitted, on standard input. The encrypted result is placed on standard output or as specified using the option --output. The document is compressed for additional security in addition to encrypting it.

alice% gpg --output doc.gpg --encrypt --recipient blake@cyb.org doc

The --recipient option is used once for each recipient and takes an extra argument specifying the public key to which the document should be encrypted. The encrypted document can only be decrypted by someone with a private key that complements one of the recipients' public keys. In particular, you cannot decrypt a document encrypted by you unless you included your own public key in the recipient list.

You can use your own public key to encrypt a document. However, as long as your private key stay private, you will be the only one able to decrypt it.

When you wrote about using your own key, you may have wanted to mention the concept of signature, which is slightly different. You can take a look at the GNU Privacy Handbook - Making and verifying signatures to learn a bit more on the subject.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.