Skip to content

Instantly share code, notes, and snippets.

@nutty7t
Created March 26, 2019 04:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nutty7t/7b49b73ff7c05093240a718d717556eb to your computer and use it in GitHub Desktop.
Save nutty7t/7b49b73ff7c05093240a718d717556eb to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
generate_key() {
gpg \
--batch \
--generate-key \
--homedir HOME_DIR \
2>/dev/null \
<<EOF
Key-Type: RSA
Key-Length: 4096
Subkey-Type: RSA
Subkey-Length: 4096
Name-Real: <real-name>
Name-Email: <email-address>
Expire-Date: 0
Passphrase: <passphrase>
%pubring key.pub
%commit
EOF
}
save_key() {
local shortid=$(gpg key.pub 2>/dev/null \
| head --lines=2 \
| tail --lines=1 --bytes=17)
mv key.pub "./GEN_KEYS/${shortid}.pub"
printf "$(date) :: Generated $(echo ${shortid} | grep -o .... | xargs)"
}
mkdir --parents HOME_DIR # ephemeral home directory
mkdir --parents GEN_KEYS # generated public keys
while true; do
start_time=${SECONDS}
generate_key
save_key
end_time=${SECONDS}
echo " in $(( end_time - start_time )) seconds..."
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment