Lo que lograrás
Configurarás Git para firmar commits y tags usando tu llave SSH existente, configurarás el archivo allowed-signers para verificación, e integrarás con GitHub o GitLab.
Por qué firma SSH
La firma SSH llegó en Git 2.34. Reutiliza la llave SSH que ya usas para pushes — sin gestión de llaves GPG separada.
Paso 1: confirmar versión Git
git --version
Paso 2: confirmar que existe llave SSH
ls -la ~/.ssh/id_ed25519*
ssh-keygen -t ed25519 -C "[email protected]"
Paso 3: configurar Git para firmar con SSH
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/id_ed25519.pub
git config --global commit.gpgsign true
git config --global tag.gpgsign true
Paso 4: probar
cd /tmp/sign-test
git init
echo "test" > file.txt
git add . && git commit -m "Test signed commit"
git log --show-signature -1
Paso 5: configurar signers permitidos
mkdir -p ~/.config/git
echo "[email protected] $(cat ~/.ssh/id_ed25519.pub)" \
>> ~/.config/git/allowed_signers
git config --global gpg.ssh.allowedSignersFile ~/.config/git/allowed_signers
Paso 6: verificar un commit
git verify-commit HEAD
git log --show-signature
git verify-tag v1.0.0
Paso 7: subir llave a tu host Git
Paso 8: firmar commits antiguos
git commit --amend --no-edit -S
git rebase -i <base> --exec 'git commit --amend --no-edit -S'
Paso 9: forzar commits firmados
gh api -X PUT repos/owner/repo/branches/main/protection \
-F required_signatures.enabled=true
Paso 10: manejar múltiples máquinas
- Llave por máquina.
- Una llave maestra.
- Llave hardware.
Firma respaldada por hardware
ssh-keygen -t ed25519-sk -O resident -C "[email protected]"
Paso 11: firmar tags
git tag -s v1.0.0 -m "Release 1.0.0"
git tag -v v1.0.0
Solución de problemas
- "gpg: skipped: No secret key" - GPG aún configurado.
- "Bad signature" en commit ajeno - su llave no está en
allowed_signers. - Host muestra "Unverified" - llave pública no subida como signing key.