Created
August 29, 2024 04:40
-
-
Save lantrix/265b35cb59ae4c9efc48ef992c8eabcc to your computer and use it in GitHub Desktop.
Migrate GPG keys - based on https://serverfault.com/questions/86048/how-to-backup-gpg
This file contains hidden or 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
# List keys | |
gpg --list-secret-keys |egrep -v 'sec|uid|ssb' | |
Populate list | |
keys="A1B2C3D4E5F67890A1B2C3D4E5F67890A1B2C3D4 FEDCBA9876543210FEDCBA9876543210FEDCBA98 1234ABCD5678EFGH1234ABCD5678EFGH1234ABCD" | |
for key in $keys; do echo "Processing $key"; gpg -k $key | grep uid; done | |
# Export | |
for key in $keys; do | |
gpg --export --armor ${key} > ${key}.pub.asc | |
gpg --export-secret-keys --armor ${key} > ${key}.priv.asc | |
gpg --export-secret-subkeys --armor ${key} > ${key}.sub_priv.asc | |
done | |
gpg --export-ownertrust > ownertrust.txt | |
# Import | |
for key in $keys; do | |
gpg --import ${key}.pub.asc | |
gpg --import ${key}.priv.asc | |
gpg --import ${key}.sub_priv.asc | |
done | |
gpg --import-ownertrust ownertrust.txt | |
# Ultimate trust - type trust, then 5 (which means "ultimate trust") | |
for key in $keys; do | |
gpg --edit-key ${key} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment