Operating System - HP-UX
1819733 Members
3041 Online
109606 Solutions
New Discussion юеВ

automated gpg script with no passphrase

 
Michael Steele_2
Honored Contributor

automated gpg script with no passphrase

Hola Mates:

Well the subject line says it all. I'm seeking a way to with this gpg command syntax to omit the gpg passphrase during encryption. Here's what I've been given:

gpg -esa -r file

Here's the basic import command of the key

gpg --import

I'm am looking for an option that goes with gpg --import to bypass the passphrase option in gpg --edit-key.

I've been through the gpg manual from the gnupg.org website and it is not intuitively obvious to me.

Anybody ever build an automated gpg script used in ftp transmissions?
Support Fatherhood - Stop Family Law
7 REPLIES 7
Steven E. Protter
Exalted Contributor

Re: automated gpg script with no passphrase

Shalom,

This won't work?

http://www.nabble.com/Automate-decryption-td19223767.html

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Michael Steele_2
Honored Contributor

Re: automated gpg script with no passphrase

Why yes, I believe this is what I'm looking for.

"...Running without a passphrase just involves removing the passphrase
from the key altogether:

gpg --edit-key (thekeyid)
passwd
(just hit enter for the new passphrase)
save ..."

Let me test this out and I'll get back to you.
Support Fatherhood - Stop Family Law
Matti_Kurkela
Honored Contributor

Re: automated gpg script with no passphrase

If the GPG secret key has been encrypted with a passphrase, the passphrase must be input to use the key.

(Note: data encryption uses only public key, which is never protected with a passphrase. But if you also sign the data, your own secret key is also needed. This is what the passphrase is for.)

So you must either:
a) remove the passphrase from the secret key, or
b) feed the passphrase to GPG non-interactively

You already got some instructions for a). I will offer you some advice for b).

From the GPG man page:
-----------
--passphrase-fd
Read the passphrase from file descriptor . Only the first line will be read from file descriptor . If you use 0 for , the passphrase will be read from stdin. This can only be used if only one passphrase is supplied.

--passphrase-file
Read the passphrase from file . Only the first line will be read from file . This can only be used if only one passphrase is supplied. Obviously, 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
Use 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.
-----------
So, using "--passphrase-fd 0" will allow you to pipe the passphrase to GPG. That will make it necessary to protect whatever the passphrase is piped from, and/or the script that does the piping. Remember that command line arguments can be visible to all users in the ps listing.

The option "--passphrase-file" requires to protect only one file that contains the passphrase. I guess this might be the easiest for you, if you can put appropriate protections (usually, chmod 600 or even 400) on the file.

MK
MK
Michael Steele_2
Honored Contributor

Re: automated gpg script with no passphrase

MK

I am using gpg version 1.2.4. And there are no arguements for --passphrase or ├в passphrase-file for this version.

Can you tell me what version has these arguemenets?

├в ├в ┬жgpg ├в version├в ┬ж├в

SEP

Here├в s where I├в m at. After first successfully building new public and secret keys using first the ├в ..gpg ├в import KEY_1├в ┬ж├в command and then the ├в ├в ┬жgpg ├в edit-key KEY_2├в ┬ж├в , and after having entered a passphrase, I am now at the point where I can not recreate the procedure minus the passphrase. Maybe you can guide me from here based upon these gpg ├в debug messages from my script.

FILENAME=FILE00096
+ gpg --debug-all -esa -r KEY112013 /home/dataxfer/BOA_positive/CA/outgoing/DEST
00096
gpg: reading options from `/home/dataxfer/.gnupg/gpg.conf'
gpg: DBG: fd_cache_open (/home/dataxfer/.gnupg/secring.gpg) not cached
gpg: DBG: iobuf-1.0: open `/home/dataxfer/.gnupg/secring.gpg' fd=3
gpg: DBG: iobuf-1.0: underflow: req=8192
gpg: DBG: iobuf-1.0: underflow: got=1239 rc=0
gpg: DBG: parse_packet(iob=1): type=5 length=443 (search.keyring.c.963)
.
.
gpg: DBG: /home/dataxfer/.gnupg/secring.gpg: close fd 3
gpg: DBG: fd_cache_close (/home/dataxfer/.gnupg/secring.gpg) new slot created
gpg: DBG: iobuf-1.0: underflow: eof
gpg: DBG: iobuf-1.0: close `'
gpg: no default secret key: secret key not available
gpg: /home/dataxfer/BOA_positive/CA/outgoing/BOA00096: sign+encrypt failed: secr
et key not available
Support Fatherhood - Stop Family Law
Steven Schweda
Honored Contributor

Re: automated gpg script with no passphrase

> I am using gpg version 1.2.4.

Yow. How old is that?

> Can you tell me what version has these
> arguemenets?

The current version, 1.4.9, has them.

http://gnupg.org/

> Maybe you can guide me from here based upon
> these gpg ├Г┬в├В ├В debug messages [...]

I'd guide to to a current version, which
probably offers a bunch of bug fixes as well
as features.
Michael Steele_2
Honored Contributor

Re: automated gpg script with no passphrase

Well, here the end of the story.

SEP post something you deserve a big 10 points.

Additional problems were encountered with extra keys added into the keyring. Two displayed errors when deleted.

Thanks All!
Support Fatherhood - Stop Family Law
Michael Steele_2
Honored Contributor

Re: automated gpg script with no passphrase

,
Support Fatherhood - Stop Family Law