GnuPG documentation is not that great for a beginner like me and I coudn't find much detailed information ouside either, I hope you can give me some guidance about this:

I am developing a wrapper for the gpg command line tool. I would like to know if I can fit on only one command line all the input information needed to generate a key pair.

Currently I have to call: gpg --gen-key and input several other pieces of information like the key type, expiration info, name, email, and comment one at a time.

I'm couldn't figure out the gpg manual to assist on this, any tips are welcome.


I believe the answer can be found in this part of the manual: Unattended GPG key generation.

As an example:

cat <<EOF | gpg2 --batch --gen-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@foo.bar
Expire-Date: 20170115
Passphrase: abc

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.