Operating System - HP-UX
1823470 Members
2467 Online
109660 Solutions
New Discussion юеВ

PGP Encryption and Signing in a script

 
Patrick Wallek
Honored Contributor

PGP Encryption and Signing in a script

I am running PGP 5.0 on an HP-UX 10.20 box.

I am trying to write a script that will encrypt and sign a file with no input from the user. The encrypt script will be called from an application that is generating EDI Transactions.

The main problem I am having is that PGP signing the encrypted file requires the input of the pass phrase for the key that is being used. That is where my problem lies. I can't get past the pass phrase input request.

Here is what I have tried so far:

/usr/uprc/local/bin/pgpe -r $RECIPIENT1 -r $RECIPIENT2 -s -o $OUTPUTFILE $INPUTFILE << ENDPGP
PGP_KEY_PASSPHRASE
ENDPGP

Here is what it does when I run the script that the above is contained in:

# ./prepare_boa /tmp/pww/refresh_cruella /tmp/pww/refresh_cruella.pgp
Encrypting file /tmp/pww/refresh_cruella into /tmp/pww/refresh_cruella.pgp.
Cannot open configuration file /.pgp/pgp.cfg
A private key is required to make a signature.
Need a pass phrase to decrypt private key:
1024 bits, Key ID XXXXXXXX, Created 2001-01-23
"Key ID Enter pass phrase:


Anyone have any ideas?
4 REPLIES 4
Mike McKinlay
Honored Contributor

Re: PGP Encryption and Signing in a script

Have you looked at the pgpk command to load the key on your server?
"Hope springs eternal."
Patrick Wallek
Honored Contributor

Re: PGP Encryption and Signing in a script

Yes, I've got the key loaded on the machine. The key I am trying to sign with is the default key for the user. But apparently when you sign it requires the keys pass-phrase. Is there any way around this?
Ralf Hildebrandt
Valued Contributor

Re: PGP Encryption and Signing in a script

I think you could do that with an "expect" script; GNU expect can be used to script interactive application; basically it "expects" a certain output from PGP ("enter passphrase:") and "answers" with the passphrase.

That should solve your problem. Documentation of expect is lousy...
Postfix/BIND/Security/IDS/Scanner, you name it...
Patrick Wallek
Honored Contributor

Re: PGP Encryption and Signing in a script

Thanks for the help guys. I found out from the bank that there are some PGP options to do this, which I expected, but my version said were unsupported. Ah well, at least it works.

What I wound up doing:

pgpe -sa INPUTFILE -r recipient -o OUTPUTFILE.PGP -u signingkey -z signingkey_passphrase +force