Add GPG YubiKey switch helper script

This commit is contained in:
2026-02-21 11:34:08 +01:00
parent 89bc5766dd
commit 96d1fb171a
2 changed files with 38 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
# gpg-switch-yubikey
Switch GPG between two YubiKeys that hold identical key material.
GPG binds secret key stubs to a specific card serial number. When you swap YubiKeys, GPG prompts you to insert the other one. This script deletes the stubs and re-learns whichever card is currently inserted.
## Install
```bash
cp gpg-switch-yubikey ~/.local/bin/
chmod +x ~/.local/bin/gpg-switch-yubikey
```
Make sure `~/.local/bin` is in your `PATH`.
## Usage
After physically swapping to a different YubiKey:
```bash
gpg-switch-yubikey
```
## Configuration
The script contains a hardcoded GPG key fingerprint. Edit the `FINGERPRINT` variable in the script to match your own key.