views:

437

answers:

1

I was sent a public key in order to decrypt a pgp-encrypted file as well as a passphrase. I imported the key with:

gpg --import publickey.asc

And verified it with

gpg --list-keys

Now, I'm trying to decrypt the file. I put the passphrase in a file called pass.txt and ran this at the command line:

gpg -d encryptedfile.txt.pgp --output encryptedfile.txt

But I get:

gpg: encrypted with ELG-E key, ID XXXXXXXXX
gpg: encrypted with 2048-bit RSA key, ID XXXXXXXXX, created 2010-03-10
      "XXXXXXXXX XXXXXXXXX (XXXXXXXXX FTP Key) <[email protected]>"
gpg: decryption failed: secret key not available

If I do gpg --list-secret-keys, this one isn't in there... How do I associate the passphrase with the imported key?

A: 

To decrypt, you typically need the private key for the key, not the public key. With public-key encryption, data is usually encrypted with the public key and decrypted with the private key.

Also, you don't "associate" the passphrase with the imported key - you enter the imported key when prompted by gpg.

Michael E
Ok... Never used it before (obviously)... Is the command to import private keys the same?
whitman6732
Went back to what I was sent, and it says "Here is the public key that they will use to encrypt the file" So, it does appear that they used the public key and not the private one...
whitman6732
@whitman6732 Yes, I believe the import command is the same. And you need the private key. Better yet, you need to create a key pair and give them your public key - that's the way PGP usually works.
Michael E
@whitman6732: They use the public key to encrypt. You cannot use that key to decrypt, you need the corresponding private key. And they should have used your public key to encrypt, not theirs. If you don't have a public key, then you need to create a keypair, send them your public key, and make sure they use that public key to encrypt.
GregS