Perche firmare
I campi autore e committer di Git sono metadati non autenticati.
Tre backend di firma
- GPG.
- SSH (Git 2.34+).
- X.509 / S/MIME.
Firma SSH (raccomandata)
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
Firmare commit esistenti
git commit --amend --no-edit -S
git rebase -i <base> --exec 'git commit --amend --no-edit -S'
Verificare firme
git log --show-signature
git verify-commit HEAD
git verify-tag v1.4.0
Tag firmati per le release
git tag -s v1.4.0 -m "Release 1.4.0"
git tag -v v1.4.0
Igiene di gestione delle chiavi
- Usare chiavi ed25519.
- Proteggere con passphrase e agente.
- Ruotare annualmente.
- Memorizzare le chiavi su hardware.