Automated Batch Subkey Creation

Sam M emunch at
Fri Sep 12 15:03:53 CEST 2014


I'm new to the list. I have some familiarity with GPG and have a particular
requirement. I really hope someone can point me to where I can get more
information on this or let me know if this is not possible.

I have to automate the following task. The result I am looking to get is a
master key pair with four sub-keys, one for encryption, two for signing and
one for authentication. Each sub-key also has to have a revocation key. I
have to do this in an automatic manner. In addition to this, I need to
separate out one signing key and the authentication key into separate files.

I have to do this in batch mode since human intervention is not possible.

At this point, I have understood how to make a master key with one sub-key
in batch mode. The GPG command and the batch file are fromhttps://

How can I automate the creation of a sub-key?

Thanks in advance.



cat >foo <<EOF
          %echo Generating a basic OpenPGP key
          Key-Type: DSA
          Key-Length: 1024
          Subkey-Type: ELG-E
          Subkey-Length: 1024
          Name-Real: Joe Tester
          Name-Comment: with stupid passphrase
          Name-Email: joe at
          Expire-Date: 0
          Passphrase: abc
          %secring foo.sec
          # Do a commit here, so that we can later print "done" :-)
          %echo done

$ gpg2 --batch --gen-key foo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/attachments/20140912/ad782bf6/attachment.html>

More information about the Gnupg-users mailing list