gpg
notes
prerequisites
-
add ykman as an execution alias
-
disable git's internal gpg and ssh services
as administratorMove-Item -Path "C:\Program Files\Git\usr\bin\gpg.exe" -Destination "C:\Program Files\Git\usr\bin\gpg_disabled.exe" Move-Item -Path "C:\Program Files\Git\usr\bin\ssh.exe" -Destination "C:\Program Files\Git\usr\bin\ssh_disabled.exe"- this may have to be repeated each time git updates
variables
| variable | description | example |
|---|---|---|
NAME |
first and last names | John Doe |
FIRST_NAME |
first name | John |
LAST_NAME |
last name | Doe |
EMAIL |
github private relay email address | 12345678+username@users.noreply.github.com |
KEY |
gpg key id | 89ABCDEF |
AUTH_KEY |
gpg authentication key id | 89ABCDEF |
AUTH_KEYGRIP |
gpg authentication keygrip | 0123456789ABCDEF0123456789ABCDEF01234567 |
PASSPHRASE |
gpg passphrase | FakePassword123 |
ADMIN_PIN |
yubikey gpg module administrator pin | default is 12345678 |
PIN |
yubikey gpg module pin | default is 123456 |
URL |
url of raw github gist of pub gpg key | https://gist.githubusercontent.com/username/.../raw/.../pub.gpg |
resources
- GPG(1)
- Signing Git commits with GPG keys that use modern encryption
- How to backup GPG?
- GPG Subkeys
- Subkeys
- SSH Authentication to GitHub Using a YubiKey on Windows
- GPG - SSH setup
- YubiKey-Guide
- Setting up GnuPG + YubiKey on NixOS for SSH authentication
- Developers Guide to GPG and YubiKey
- ssh github works, but not git push
- SSH Authentication with GPG
brief
- this opinionated guide shows how to create a gpg key with subkeys, copy relevant gpg key data to any number of yubikeys, enabling usage of those yubikeys for signing (via gpg) and authentication (via gpg/ssh)
- I hope to amend this guide in the future to avoid the mirroring of yubikeys
gpg setup
creating gpg key
- find KEY now
- pub gpg key is in the clipboard
make sure you've...
- added the pub gpg key to your github user settings under gpg keys
- added the pub gpg key to a github gist for public availability
backing up gpg key
make sure you've...
- copied the following three backups from
~/Downloadssomewhere safe (e.g. bitwarden):- a pub gpg key backup
- a priv gpg key backup
- a priv gpg subkeys backup
configuring yubikey(s)
admin kdf-setup | 12345678 | "OK" passwd | 3 | 12345678 | "OK" | $ADMIN_PIN | "OK" | $ADMIN_PIN | "OK" | 1 | 123456 | "OK" | $PIN | "OK" | $PIN | "OK" | q name | $LAST_NAME | $FIRST_NAME | $ADMIN_PIN | "OK" lang | en url | $URL login | $EMAIL key-attr | 2 | 1 | $ADMIN_PIN | "OK" | 2 | 1 | $ADMIN_PIN | "OK" | 2 | 1 | $ADMIN_PIN | "OK" fetch quit
note that...
- you should repeat all steps from this section for each yubikey
configuring gpg/ssh auth
- find AUTH_KEY now
- find AUTH_KEYGRIP now
- gpg/ssh key is in the clipboard
make sure you've...
- added the gpg/ssh key to your github user settings under ssh keys
configuring git
gpg tools
connecting yubikey
importing gpg key
make sure you've...
- copied an old pub gpg key backup to
~/Downloads
- DATE is the date of the pub gpg key backup to-be imported (e.g. 2025-01-01)
- KEY is the backed up pub gpg key id
make sure you've...
- imported a pub gpg key
- copied an old priv gpg key backup to
~/Downloads
- DATE is the date of the priv gpg key backup to-be imported (e.g. 2025-01-01)
- KEY is the backed up priv gpg key id
make sure you've...
- imported a pub gpg key
- copied an old priv gpg subkeys backup to
~/Downloads
- DATE is the date of the priv gpg subkeys backup to-be imported (e.g. 2025-01-01)
- KEY is the backed up priv gpg key id
revoking gpg key
make sure you've...
- find KEY now
make sure you've...
- removed the pub gpg key from your github user settings under gpg keys
make sure you've...
- find KEY now
deleting gpg key
make sure you've...
- find KEY now