Add YubiKey new-machine setup script

Self-contained setup.sh that imports the bundled public key, binds the YubiKey
card stubs, enables SSH via the auth key, and configures git signing — so a
fresh machine is provisioned without hunting for the public key. Idempotent and
verified end to end.
This commit is contained in:
2026-07-24 19:28:15 +02:00
parent 68460f499b
commit 0868ce16aa
5 changed files with 258 additions and 26 deletions
+12
View File
@@ -0,0 +1,12 @@
#!/bin/bash
# Re-learn the currently inserted YubiKey for GPG
FINGERPRINT="4A227DDEFA7A37048609549863C6571F1095CC5C"
KEYGRIPS=$(gpg --with-keygrip --list-secret-keys "$FINGERPRINT" 2>/dev/null | grep Keygrip | awk '{print $3}')
for kg in $KEYGRIPS; do
rm -f ~/.gnupg/private-keys-v1.d/${kg}.key
done
gpgconf --kill gpg-agent
gpgconf --kill scdaemon
sleep 1
gpg --card-status > /dev/null 2>&1 && echo "Switched to $(gpg --card-status 2>/dev/null | grep 'Serial number' | awk '{print $NF}')" || echo "No card found"