Skip to content

Instantly share code, notes, and snippets.

@ftorto
Created February 12, 2018 21:53
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 ftorto/30398a13656f991f07b568fe8dc05007 to your computer and use it in GitHub Desktop.
Save ftorto/30398a13656f991f07b568fe8dc05007 to your computer and use it in GitHub Desktop.
Remove primary secret key from .gnupg
# Your fingerprint
gpgKey=0x1234123123123
# Export the full backup to store somewhere
gpg --export-secret-keys --armor ${gpgKey} > ${gpgKey}.full_backup.asc
# Export partial backup with only your subkeys
gpg --export-secret-subkeys --armor ${gpgKey} > ${gpgKey}.only_subkeys.asc
# Erase your .gnupg
mv --no-clobber ~/.gnupg ~/.gnupg.BAK
gpg2
#ctrl+c
cp ~/.gnupg.BAK/gpg.conf ~/.gnupg
rm -rf ~/.gnupg.BAK
# Import partial backup
gpg --import ${gpgKey}.only_subkeys.asc
gpg --list-secret-keys gpg ${gpgKey}
# You see `sec# ` meaning the primary secret key is missing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment