1

I am trying to encrypt a file with multiple public keys and used the same syntax that is there as part of the documentation and it is throwing the below error.

Error Message

gpg : usage: gpg [options] --encrypt [filename] At line:10 char:1 + gpg --encrypt \ --recipient "Sree" \ --recipient "Matam" \ "C:Reports\ ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (usage: gpg [opt...rypt [filename]:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError

P.S: This encryption is done as part of a powershell script

When I encrypt with a single key, it works fine. Can someone point what is it that I am doing wrong?

gpg --encrypt \ --recipient "Sree" \ --recipient "Matam" \ "C:\Reports\test_encryption.xlsx"

I used this thread to guide me but looks like I am missing something

Encryption with multiple different keys?

5
  • What "below error" ? Commented Jul 14, 2016 at 0:45
  • How will the two users access the file, will you provide custom decryption code? Commented Jul 14, 2016 at 10:57
  • 2
    I probably wasn't clear. My apologies. I want to encrypt the file with the public keys of 2 different users so that each can decrypt it with his/her own private keys. It is possible through Kleopatra and we are trying to automate this manual task via powershell. Commented Jul 14, 2016 at 14:32
  • 2
    Try: gpg -r "Sree" -r "Matam" --encrypt C:\Reports\test_encryption.xlsx. This 1) places the options (-r/--recipient) before the command and it 2) removes the slashes that don't work that way in powershell Commented Jul 14, 2016 at 16:45
  • That was close. Thank you. Got it to work finally with this piece of code code $BeforeEncryptfilePathGPG = "C:\Reports\Test_Encryption.xlsx" $SignedOrEncryptedLoc = "C:\Reports\Test_Encryption.xlsx.gpg" gpg --output $SignedOrEncryptedLoc --always-trust --encrypt --recipient "Sreekar" --recipient "Matam" $BeforeEncryptfilePathGPG code Commented Jul 14, 2016 at 18:22

2 Answers 2

2

You encrypt with one key at a time.

Once you have encrypted with one key, you may re-encrypt the ciphertext with a second key.

However, this serves no semantically legitimate purpose. Public keys are used to provide secrecy and confidentiality in the prescribed manner. I sign something with my private key and encrypt it for you with your public key. You recover it with your private key and verify it with my public key. Any superjacent use of this public key or that private key is questionable at best.

Sign up to request clarification or add additional context in comments.

1 Comment

I have two different users who should be able to access the file with their own keys. If I encrypt the file and run the encryption script on top of it again, wouldn't it create a file with .gpg.gpg extension. So to access the file, the user would need the key of the other user too which wouldn't work. Please correct me if I am thinking wrong here.
1

Got this bit to work finally. Thanks to @user2864740

$BeforeEncryptfilePathGPG = "C:\Reports\Test_Encryption.xlsx"
$SignedOrEncryptedLoc = "C:\Reports\Test_Encryption.xlsx.gpg"
gpg --output $SignedOrEncryptedLoc --always-trust --encrypt --recipient "Sreekar" --recipient "Matam" $BeforeEncryptfilePathGPG

1 Comment

It is giving me error what I'm missing in this?? gpg : gpg: Matam: skipped: No public key

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.