Created
March 27, 2019 22:54
-
-
Save chmduquesne/0591424ef8f2695d5af42bb16e457355 to your computer and use it in GitHub Desktop.
gpg maintenance
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
ifdef GNUPGHOME | |
CONF := ${GNUPGHOME}/gpg.conf | |
else | |
CONF := ~/.gnupg/gpg.conf | |
endif | |
DEFAULTKEY = $(shell gpg -K --with-colons | grep "^sec" | cut -d: -f5 | tail -n1) | |
DEFAULTFPR = $(shell gpg -K --with-colons | grep "^fpr" | grep $(DEFAULTKEY) | rev | cut -d: -f2 | rev) | |
export: | |
gpg --export-secret-keys > secret-keys.gpg | |
gpg --export-ownertrust > ownertrust.gpg | |
[ -f ${CONF} ] && cp ${CONF} gpg.conf || true | |
import: | |
gpg --import secret-keys.gpg | |
gpg --import-ownertrust ownertrust.gpg | |
[ -f gpg.conf ] && cp gpg.conf ${CONF} || true | |
new-key: | |
#gpg --quick-gen-key $(UID) rsa4096 cert never | |
gpg --full-gen-key | |
add-subkeys: | |
gpg --quick-add-key $(DEFAULTFPR) rsa4096 encr 1m | |
gpg --quick-add-key $(DEFAULTFPR) rsa4096 sign 1m | |
gpg --quick-add-key $(DEFAULTFPR) rsa4096 auth 1m | |
strip-master: | |
gpg --output secret-subkeys.gpg --export-secret-subkeys $(DEFAULTKEY) | |
gpg --yes --delete-secret-keys $(DEFAULTKEY) | |
gpg --import secret-subkeys.gpg | |
rm secret-subkeys.gpg | |
new: | |
$(MAKE) new-key | |
$(MAKE) add-subkeys | |
$(MAKE) export | |
$(MAKE) strip-master | |
renew: | |
$(MAKE) import | |
$(MAKE) add-subkeys | |
$(MAKE) export | |
$(MAKE) strip-master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment