Last active
October 31, 2024 23:23
-
-
Save woods/8970150 to your computer and use it in GitHub Desktop.
Creating gpg keys non-interactively
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Key-Type: 1 | |
Key-Length: 2048 | |
Subkey-Type: 1 | |
Subkey-Length: 2048 | |
Name-Real: Root Superuser | |
Name-Email: [email protected] | |
Expire-Date: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate the key | |
gpg --batch --gen-key gen-key-script |
Add %no-protection
if you need to generate passwordless keys. This also prevents the pinentry to pop up.
Using Process Substitution can be support indentation
gpg --full-gen-key --batch <(echo "Key-Type: 1"; \
echo "Key-Length: 4096"; \
echo "Subkey-Type: 1"; \
echo "Subkey-Length: 4096"; \
echo "Expire-Date: 0"; \
echo "Name-Real: Root Superuser"; \
echo "Name-Email: [email protected]"; \
echo "%no-protection"; )
Quick question for you, do you know if it's possible to use --batch
to create a master key and subsequent subkeys (3 to 4 at a time)?
I want to follow this guide: https://github.com/drduh/YubiKey-Guide and create a script that would create the master key and sub keys at the same time. After some research, I'm left with 'it can only generate 1 subkey' so I'm stuck right now
If you have an idea, could you share it?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was more of an FYI note, I found how to resolve the issue https://www.gnupg.org/documentation/manuals/gnupg/Unattended-GPG-key-generation.html
Not sure what is different, but the code given on that page worked :)