Por Anónimo (no verificado) , 29 Abril 2026

Por qué firmar

Los campos de autor y committer de Git son metadatos no autenticados — cualquiera puede afirmar ser otro. Para proyectos donde la autoría importa, las firmas criptográficas vinculan un commit a una llave real.

Tres backends de firma

  • GPG - tradicional, soportado en todas partes.
  • SSH - reutiliza tu llave SSH (Git 2.34+).
  • X.509 / S/MIME - para empresas con infraestructura PKI.

Firma SSH (recomendada)

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
echo "[email protected] $(cat ~/.ssh/id_ed25519.pub)" \
  >> ~/.config/git/allowed_signers
git config --global gpg.ssh.allowedSignersFile ~/.config/git/allowed_signers

Firma GPG

gpg --full-generate-key
gpg --list-secret-keys --keyid-format=long
git config --global user.signingkey 3AA5C34371567BD2
git config --global commit.gpgsign true
gpg --armor --export 3AA5C34371567BD2

Firmar commits existentes

git commit --amend --no-edit -S
git rebase -i <base> --exec 'git commit --amend --no-edit -S'

Verificar firmas

git log --show-signature
git verify-commit HEAD
git verify-tag v1.4.0

Forzar firmas

La protección de branch en GitHub y GitLab puede requerir commits firmados antes del merge.

Tags firmados para releases

git tag -s v1.4.0 -m "Release 1.4.0"
git tag -v v1.4.0

Higiene de gestión de llaves

  • Usa llaves ed25519 (o RSA 4096+).
  • Protege con passphrase y un agent.
  • Rota llaves anualmente.
  • Almacena llaves en hardware (YubiKey) para alta seguridad.