0
$\begingroup$

I'm writing a web interface in PHP to generate keys. I'm familiar with gpg's command line options, particularly --batch. I'm also familiar with PHP's GnuPG API.

I can't find a way to safely pass the user's password from the web interface to the gpg command line because gpg uses a pinentry program? PHP's GnuPG functions don't include an API to generate keys.

What other way is there to generate keys, unattended, other than creating a batch file with the passphrase in that file like so:

Key-Type: default
Subkey-Type: default
Name-Real: Bob
Name-Email: bob@gmail.com
Expire-Date: 2021-12-25
Passphrase: mysecretpassphrase
%commit

Note: putting the passphrase on the command line with --passphrase is not wise.

Thanks!

$\endgroup$
1
$\begingroup$

I finally found the answer by reading the whole manual.

$ man gpg says around line 1944:

--passphrase-fd n

Read the passphrase from file descriptor n.

and

--passphrase-file file

Read the passphrase from the file.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.