-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path,gpg-new
executable file
·50 lines (33 loc) · 977 Bytes
/
,gpg-new
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
# USAGE: ,gpg new
# DESCRIPTION: Create new GPG key
USERNAME="$USER"
EMAIL="[email protected]"
# Define the key type and key length (you can adjust these as needed)
KEY_TYPE="RSA"
KEY_LENGTH="4096"
# Generate the GPG key
# REVIIST: Fix this command
print-cmd gpg --batch --generate-key --pinentry-mode loopback
gpg --batch --generate-key --pinentry-mode loopback <<EOF
Key-Type: $KEY_TYPE
Key-Length: $KEY_LENGTH
Name-Real: $USERNAME
Name-Email: $EMAIL
Expire-Date: 0
EOF
RETVAL=$?
((RETVAL)) && exit "$RETVAL"
ls
# Output the public key
gpg --armor --export "$USERNAME" > "${USERNAME}_public_key.asc"
echo "New GPG key generated and saved as ${USERNAME}_public_key.asc"
exit
gpg_args=()
gpg_args+=(--expert)
gpg_args+=(--full-generate-key)
# Why doesn’t GnuPG default to using RSA-4096?
# https://www.gnupg.org/faq/gnupg-faq.html#no_default_of_rsa4096
#gpg_args+=(--size 3072)
#gpg_args+=(--cipher-algo AES256)
gpg "${gpg_args[@]}"