cannot pass in input and passphrase at the same time in batch mode?

Steven W. Orr steveo at syslang.net
Tue Jun 23 06:18:01 CEST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 06/22/09 22:25, quoth Joe Korn:
> Hi Harry,
> 
> We ran into the same problem and the only way we were able to get around it
> was by storing the pass phrase in a file and using the TYPE command instead
> of the echo.  Curious to see if anyone else found a better solution
> 
> Regards,
> 
> Joe K

I'm gonna go out on a limb here and suggest that gpg is not going to look for
a passphrase from stdin. Instead it's going to look for input from /dev/tty.
IF I'm right (and I'm just guessing here) then the only way to get what you're
trying to do is to write your program in expect.

Expect: The program for people who have to be running from a console.

> 
> On Thu, Jun 18, 2009 at 8:41 PM, Harry<lufei at yahoo.com> wrote:
>> Hello guys,
>> 
>> I ran into a problem when using gpg to sign and encrypt. I have a test
>> run below (in bash):
>> 
>> $echo abcd | gpg -u bob at xyz.com --output message.pgp -r alice at 123.com -se
>> --passphrase-fd 0 << EOF <123456 <EOF
>> 
>> There is no error but after decrypt message.pgp, the file content is
>> empty. In above run, "abcd" is the input plain text to be encrypted,
>> 123456 is the passphrase for bob at xyz.com's private key that is used for
>> signing the file.
>> 
>> My requirements are "abcd" can not be saved in a file, it has to be sent
>> to gpg as stdin. So is the passphrase, it can not be saved in a file too.
>> 
>> 
>> It looks like when input and passphrase are all passed in as stdin, gpg
>> only takes passphrase and consider input text as empty, which result into
>> an empty encrypt file.
>> 
>> Is there anyway to solve this?
>> 
>> I tried
>> 
>> $echo abcd | gpg -u bob at xyz.com --batch --output message.pgp -r
>> alice at 123.com -se --passphrase "123456"
>> 
>> but gpg gave error like: gpg: skipped `bob at xyz.com': bad passphrase gpg:
>> [stdin]: sign+encrypt failed: bad passphrase
>> 
>> Thanks!

- --
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkpAV3kACgkQRIVy4fC+NyQ6/QCeO2WdyaJ/4lbqPPpUa53m0EJI
0k0An0ThpG/QG2uCw1Z3qgJD5e9E9leL
=sBym
-----END PGP SIGNATURE-----



More information about the Gnupg-users mailing list