Created
March 26, 2019 04:34
-
-
Save nutty7t/7b49b73ff7c05093240a718d717556eb to your computer and use it in GitHub Desktop.
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
#!/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