Skip to content

Instantly share code, notes, and snippets.

@wildlarva
Last active August 20, 2023 02:43
Show Gist options
  • Save wildlarva/ba37203f693744b631c7954e6cda933c to your computer and use it in GitHub Desktop.
Save wildlarva/ba37203f693744b631c7954e6cda933c to your computer and use it in GitHub Desktop.
Useful GPG commands

Useful commands for GPG

Check public key

# List public keys
gpg --list-keys

Backup and restore

# List private keys
gpg --list-secret-keys --keyid-format=long

# Export private key
gpg --armor --export-secret-keys <key-id> > <key-file>

# Import private key
gpg --import <key-file>

# Change trust level manually
gpg --edit-key <key-id> trust quit

# Export ownertrust
gpg --export-ownertrust > <ownertrust-file>

# Import ownertrust
gpg --import-ownertrust < <ownertrust-file>

Commit with GPG key

# Tell Git about GPG key
git config --global user.signingkey <key-id>

# Config Git to commit with GPG key
git config --global commit.gpgsign true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment