GPG master and subkeys
The purpose of GPG master and subkey design is to keep a master key locked up, and using subkeys for everyday signing or encryption operations
To check if you have keys already use
gpg --list-keysUse this command to find ID or email during the process
Create a master key
Master key will be the offline parent of all your daily usage subkeys
Ideally created on an offline computer
gpg --full-generate-key- type ECC (sign only)
- select to not expire
Generate revocation certificate for master key
This can be used later if you loose the key or it's compromised
gpg --output master-revocation.asc --gen-revoke (email or ID)Backup master key
Transfer this to offline safe space along with revocation certificate
gpg --output master-key-backup.gpg --export-secret-keys (email or ID)Create subkey
Locate your key and edit it:
gpg --edit-key (email or ID)Add new subkey
addkey- choose ECC (sign only) or ECC (encrypt only)
- select to expire in 1y etc
You will be prompted for master key passphrase
Export subkey
Export and encrypt with password before transer to online computer
gpg --output subkeys.gpg --export-secret-subkeys (email or ID)
gpg --symmetric subkeys.gpg
rm subkeys.gpgExport public key of master key
This will also contain subkeys
gpg --output public-key.asc --export (email or ID)Transfer and import subkeys
gpg --output subkeys.gpg --decrypt subkeys.gpg.gpg
gpg --import subkeys.gpgVerify that master private key is not in the online machine:
gpg --list-secret-keysThe key will list at the top but it will state "sec#" with a hash to confirm there is no actual secret key on the machine
import public keys (not sure if this is needed)
gpg --import public-key.ascTrust your own keys
gpg --edit-key (email or ID)Exporting public subkey for signing in Github
gpg --armor --export 889167D844EAD4C3Upload your public master key
gpg --keyserver hkps://keys.openpgp.org --send-keys 6CE1EA2A5439398B4389A4F8CF44D1B60C2E81E6Verify and check wether you need to update
gpg --keyserver hkps://keys.openpgp.org --recv-keys 6CE1EA2A5439398B4389A4F8CF44D1B60C2E81E6Managing keys
So after a while your subkeys will expire. Then you
- create new subkeys
- export and upload your public keys to keyserver
Edit keys
If you made a mistake or something on master key subkey, you can edit them.
First enter edit mode by master key like when you create new subkey
Then list all
listSelect key (0 is first key / master)
key 1Now selected key will be prefixed by *
Now edit expire date
expire