brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: sign your git commits with the SSH key you already have

Git
~/tips/tip-git-sign-commits-ssh-key

git config --global gpg.format ssh

Signs commits with an SSH key instead of GPG, with three config lines.

Signing commits used to mean setting up GPG, which I think a lot of people put off. Since git 2.34 an SSH key can sign commits too, and most of us have one already.

git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/id_ed25519.pub
git config --global commit.gpgSign true

The first line switches signing from GPG to SSH, the second points at the public key (git finds the private key next to it, or in your SSH agent), and the third signs every commit without you adding -S. Add tag.gpgSign true if you want signed tags as well.

On GitHub, add the same public key under your SSH keys as a signing key, not only as an authentication key. Then commits show as verified there.

Checking signatures locally needs one more file: a list of trusted keys. Each line is an email followed by the public key:

echo "[email protected] $(cat ~/.ssh/id_ed25519.pub)" > ~/.ssh/allowed_signers
git config --global gpg.ssh.allowedSignersFile ~/.ssh/allowed_signers
git log --show-signature -1

Without that file, git log --show-signature complains even for your own good signatures. And if your key has a passphrase and isn’t in the agent, every commit asks for it, so load it with ssh-add first.

Further reading: git-config documentation: gpg.format, GitHub: about commit signature verification

Going deeper: Moving on from hdtv: how to export your TV show list to Trakt.tv

More Git tips git show-branch main feature git log --stat -5 git merge --no-ff feature -m "Merge feature" git merge --squash feature git merge --abort All Git tips (144) All topics

Link