Created
September 10, 2019 18:54
-
-
Save michaelfranzl/f4582192437d98c2485c1133f81abdeb to your computer and use it in GitHub Desktop.
Automate GPG to generate a Curve25519 primary key, and Curve25519 subkeys for signing, encrypting and authenticating.
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
#!/bin/bash | |
# Automate GPG to generate a Curve25519 primary key, | |
# and Curve25519 subkeys for signing, encrypting and authenticating. | |
# | |
# Developed for gpg (GnuPG) 2.2.12. | |
# | |
# Copyright (c) 2019 Michael Karl Franzl | |
# | |
# Copying and distribution of this file, with or without modification, | |
# are permitted in any medium without royalty provided the copyright | |
# notice and this notice are preserved. This file is offered as-is, | |
# without any warranty. | |
# | |
# https://www.gnu.org/licenses/license-list#GNUAllPermissive | |
read -p 'Enter your full name: ' full_name | |
read -p 'Enter e-mail: ' email | |
read -s -p 'Enter Passphrase: ' passphrase | |
gpg_generate_key_args="--status-fd=2 --command-fd=0 --full-generate-key --expert --pinentry-mode loopback" | |
gpg_edit_key_args="--status-fd=2 --command-fd=0 --expert --pinentry-mode loopback --edit-key ${email}" | |
function create_primary_key { | |
gpg ${gpg_generate_key_args} << EOF | |
11 | |
S | |
Q | |
1 | |
50y | |
${full_name} | |
${email} | |
${passphrase} | |
EOF | |
} | |
function create_sign_subkey { | |
gpg ${gpg_edit_key_args} << EOF | |
addkey | |
10 | |
1 | |
2y | |
${passphrase} | |
save | |
EOF | |
} | |
function create_encrypt_subkey { | |
gpg ${gpg_edit_key_args} << EOF | |
addkey | |
12 | |
1 | |
2y | |
${passphrase} | |
save | |
EOF | |
} | |
function create_authenticate_subkey { | |
gpg ${gpg_edit_key_args} << EOF | |
addkey | |
11 | |
S | |
A | |
Q | |
1 | |
2y | |
${passphrase} | |
save | |
EOF | |
} | |
create_primary_key | |
create_sign_subkey | |
create_encrypt_subkey | |
create_authenticate_subkey |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment