Skip to content

Instantly share code, notes, and snippets.

@woods
Last active March 12, 2024 12:00
Show Gist options
  • Star 62 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save woods/8970150 to your computer and use it in GitHub Desktop.
Save woods/8970150 to your computer and use it in GitHub Desktop.
Creating gpg keys non-interactively
Key-Type: 1
Key-Length: 2048
Subkey-Type: 1
Subkey-Length: 2048
Name-Real: Root Superuser
Name-Email: root@handbook.westarete.com
Expire-Date: 0
# Generate the key
gpg --batch --gen-key gen-key-script
@eexit
Copy link

eexit commented Jan 27, 2022

Add %no-protection if you need to generate passwordless keys. This also prevents the pinentry to pop up.

@muink
Copy link

muink commented Feb 27, 2023

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: root@handbook.westarete.com"; \
                             echo "%no-protection"; )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment