Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Security
User Name
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.


  Search this Thread
Old 10-10-2011, 12:00 PM   #1
LQ Newbie
Registered: Oct 2011
Posts: 1

Rep: Reputation: Disabled
decrypt pgp file using gpg and passphrase

I'm trying to decrypt a file received from external source and i would like to know all the steps that i need to setup for decrypting the file. I tried couple of ways but it keeps asking about secret key not available.

gpg --output "/tmp/xxx.txt" --decrypt "/tmp/xxx.pgp"
gpg: encrypted with ELG-E key, ID 98F004C9
gpg: decryption failed: secret key not available

and if i try to use different option where in I pass passphrase i got i still get same error.

echo pphrase|gpg --passphrase-fd 0 --always-trust --batch --yes --quiet --output "/tmp/xxx.txt" --decrypt "/tmp/xxx.pgp"
gpg: decryption failed: secret key not available

Could you all please tell what kind of setup i need to make for this to work. Do I need to install some kind of key ring in some directory. If so in which directory should i install? in my home directory or in some common place which is accessible to all users. And finally what is the key.I went through some documentation online and could not get to the point.

What all should I need when i receive a encrypted file from someone and all the setup that I need to make on my server.

Old 10-10-2011, 02:31 PM   #2
Ian John Locke II
Registered: Mar 2008
Location: /dev/null
Distribution: Slackware, Android, Slackware64
Posts: 130

Rep: Reputation: 17
I only recently (a few days ago) started diving into pgp/gpg. It seems to me, and I could be wrong, that when someone encrypts a file/message to send to you, they need to use your public key to encrypt it. Your public key is generated from your private key. To have a key in the first place you need to run
gpg --gen-key
This link should help though:

Also the output of your original command tells you that it was encrypted with ElGamal and gives you the key's ID.
If you know which keyserver (if any) the person used, you can use
gpg --keyserver --recv-key 98F004C9
To get their key. It may be that they encrypted it in such a way that you can decrypt it.

Last edited by Ian John Locke II; 10-10-2011 at 02:37 PM. Reason: Add more helpful information
Old 10-10-2011, 02:50 PM   #3
Senior Member
Registered: Jul 2007
Distribution: Gentoo
Posts: 2,125

Rep: Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781
Ian John Locke II is correct in that files need to be encrypted with your (the recipient) key, not the sender's key. Files can be encrypted with a public key, which one normally publishes on key servers after generating it. File encrypted with the public key can only be decrypted with the private key. Using the recv-key command as shown above will obtain the public key, which can be used to send to that recipient, but unless that is your private key, you won't be able to decrypt anything encoded with it.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
file descriptors in Perl-----I need to use gpg's "--passphrase-fd n" option Rain Duck Programming 5 02-25-2011 10:52 AM
Can't decrypt anything with GPG Jorophose Linux - Security 2 12-06-2007 05:57 PM
Cracking a gpg pgp key (passphrase) DaRkBoDoM Linux - Security 1 11-20-2007 04:32 AM
Can't decrypt a file; Pgp error Msg. follows drmjh Linux - Newbie 7 05-17-2007 02:48 PM
KMail and PGP/GPG not working - doesn't ask for passphrase steve1401 Linux - General 2 02-08-2005 07:42 AM > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 10:25 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration