Skip to content

Instantly share code, notes, and snippets.

@steinybot
Last active March 7, 2022 00:46
Show Gist options
  • Save steinybot/95ba1aae19007a56ab86e163c93e7422 to your computer and use it in GitHub Desktop.
Save steinybot/95ba1aae19007a56ab86e163c93e7422 to your computer and use it in GitHub Desktop.
GPG Commands

GPG Commands

Miscellaneous

HP laptop boot loader menu key: F9

List

Listing keys:

gpg --list-keys
gpg --keyid-format SHORT --list-keys
gpg --keyid-format LONG --list-keys
gpg --keyid-format 0xLONG --list-keys
gpg --list-secret-keys
# Subkeys are hidden if they have expired.
gpg --list-keys --list-options show-unusable-subkeys
# Show it all
gpg --list-keys --with-keygrip --with-fingerprint --with-subkey-fingerprints --keyid-format 0xlong --list-options show-unusable-subkeys

Adding Subkeys

Edit the key:

gpg --expert --edit-key 0x21DE1CAE59762A0F

Add key:

gpg> addkey

Adding Identities

Edit the key:

gpg --expert --edit-key 0x21DE1CAE59762A0F

Add identity:

gpg> adduid

ℹ️ You need to resign all your subkeys in order to use this new identity.

Expiration

Key

Edit the key:

gpg --edit-key 0x21DE1CAE59762A0F

Set the new expiry:

gpg> expire
gpg> save

Subkeys

Edit the key:

gpg --edit-key 0x21DE1CAE59762A0F

Select the subkeys and set the new expiry:

gpg> key 1
gpg> key 2
gpg> key 3
gpg> expire
gpg> save

Exporting

Public Key

Export the public key (which includes the public subkeys):

gpg --armor --output /media/amnesia/SECURE/0x21DE1CAE59762A0F.pub.asc --export 0x21DE1CAE59762A0F

Secret Subkey

Export the secret subkey:

gpg --armor gpg --output /media/amnesia/SECURE/0xC4A8C75C7876F1B5.sec.asc --export-secret-subkeys 0xC4A8C75C7876F1B5!

⚠️ Don't forget to put the ! at the end of the key id.

Importing

Public Key

Import the public key (which includes the public subkeys):

gpg --import 0x21DE1CAE59762A0F.pub.asc

Secret Subkey

First delete the existing subkeys:

gpg --edit-key 0x21DE1CAE59762A0F
gpg> key 1
gpg> key 2
gpg> key 3
gpg> delkey
gpg> save

Then import the secret subkeys:

gpg --import /Volumes/PATRICK/0xC4A8C75C7876F1B5.sec.asc
gpg --import /Volumes/PATRICK/0x3D1C7D5C8E2FF8AE.sec.asc
gpg --import /Volumes/PATRICK/0x7D3DD2E3A364DA82.sec.asc

⚠️ Don't forget to delete the secret key files once you have imported them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment