1

I'm trying to use OpenGPG and when trying to decrypt something It opens up a prompt for the password. Now I'm trying to run this automatically therefore none to enter password. So My question is how do you pass in the password to this new prompt opened up by the exe I'm running form the batch file. Ive looked in gpg2.exe -help and there is no way to pass in the password as a parameter if anyone is familiar with OpenGPG or if there is a command I can run to pass the password into the new prompt, that would be great.

gpg2.exe -o output.txt -d series.txt.gpg
Jens Erat
  • 37,523
  • 16
  • 80
  • 96

3 Answers3

1

After many attempts at trying to get this working I, finally checked out the manual for gpg2.exe at http://linux.die.net/man/1/gpg2 and after adding the command line argument --batch the --passphrase is accepted by the application.

Not doing so results in the user being prompted.

Hope this helps anyone in the future attempting to do this hack.

0

echo password | gpg2.exe -o output.txt -d series.txt.gpg

cure
  • 2,588
  • 1
  • 17
  • 25
  • unfortunately that did not work. It doesn't seem to do anything. – user1938919 Oct 21 '13 at 19:06
  • this should use the echo command's stdout as the gpg2.exe's stdin. what happens if you replace password with a random string, does it say invalid password or some such thing? – cure Oct 21 '13 at 19:45
  • no I don't receive any kind of response by placing echo pass | gpg2.. in there. It doesn't seem to do anything. – user1938919 Oct 21 '13 at 19:56
  • try `(echo.&echo password)|gpg2.exe -o output.txt -d series.txt.gpg` ; ) sorry, I can't try any of this myself, I am on a friends computer and I can't download the executable to try it... – cure Oct 21 '13 at 21:10
0

GnuPG offers multiple ways to pass the passphrase non-interactively. Using the parameter --passphrase [password] is probably the most simple one, depending on your use case the others also could be of interest (for example if you do not want to store the passphrase within your application code).

From man gpg:

   --passphrase-fd n
          Read the passphrase from file descriptor n. Only the first line will be read
          from file descriptor n. If you use 0 for n, the passphrase will be read from
          STDIN. This can only be used if only one passphrase is supplied.

   --passphrase-file file
          Read  the  passphrase  from file file. Only the first line will be read from
          file file. This can only be used if only one passphrase is  supplied.  Obvi-
          ously,  a  passphrase  stored in a file is of questionable security if other
          users can read this file. Don't use this option if you can avoid it.

   --passphrase string
          Use string as the passphrase. This can only be used if only  one  passphrase
          is  supplied.  Obviously,  this is of very questionable security on a multi-
          user system. Don't use this option if you can avoid it.
Jens Erat
  • 37,523
  • 16
  • 80
  • 96