-1

How should I encrypt a file using gpg linux command with PGP public key?

I have searched on google and I found this command

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

but I didn't find where to keep the public key in the command.

Sravanth Kothuri
  • 211
  • 1
  • 3
  • 11

2 Answers2

4

If, as you said, you already have a key file, then you need to gpg --import that key into your keyring.

After that, you can gpg --list-keys to see the email address that you have to use as the argument to --recipient.

hymie
  • 1,982
  • 1
  • 13
  • 18
0

You have already specified it using --recipient option. Please check manual page or try gpg --help.

Rishikesh Darandale
  • 3,222
  • 4
  • 17
  • 35
  • I don't want --recipient option. I wan't the file to encrypt using pgp public key. – Sravanth Kothuri Sep 14 '17 at 15:29
  • Can you elaborate more? – Rishikesh Darandale Sep 14 '17 at 15:32
  • `gpg --encrypt --recipient someone@something.com secret.txt` will encrypt file `secret.txt` using public key `someone@something.com` and produce `secret.txt.gpg` – Rishikesh Darandale Sep 14 '17 at 15:35
  • I have no idea about the gpg command. So you mean "someone@something.com" is public key but here I don't have any such user as public key. I have a file with pgp public key which will be similar like -----BEGIN PGP PUBLIC KEY BLOCK----- *************************** -----END PGP PUBLIC KEY BLOCK----- – Sravanth Kothuri Sep 14 '17 at 16:14
  • Okay. Now I get you. I thought that you have imported the key using `gpg`. Use `gpg --import new.gpg` where `new.gpg ` is public key file. Once this is done verify it with `gpg --list-keys`. – Rishikesh Darandale Sep 14 '17 at 17:17