Skip to content

Instantly share code, notes, and snippets.

@devenes
Created March 23, 2026 23:21
Show Gist options
  • Select an option

  • Save devenes/ea4b6f8a9936e34e9f07c9b2c4570e1b to your computer and use it in GitHub Desktop.

Select an option

Save devenes/ea4b6f8a9936e34e9f07c9b2c4570e1b to your computer and use it in GitHub Desktop.
Step-by-step guide to automatically sign Git commits with SSH keys and display the Verified badge on GitHub.

πŸ” Git SSH Commit Signing Setup

Automatically sign all your Git commits and get the βœ… Verified badge on GitHub.


Prerequisites

  • Git installed
  • A GitHub account

Step 1 β€” Generate an SSH Key

ssh-keygen -t ed25519 -C "[email protected]"
  • Press Enter to accept the default path (~/.ssh/id_ed25519)
  • Optionally, set a passphrase for extra security or press Enter to skip

Step 2 β€” Add Your Key to the SSH Agent

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

Step 3 β€” Add SSH Key to GitHub for Authentication

  1. Copy your public key:
cat ~/.ssh/id_ed25519.pub
  1. On GitHub: Settings β†’ SSH and GPG keys β†’ New SSH key
Field Value
Title e.g. My Laptop
Key type Authentication Key
Key Paste your public key

Step 4 β€” Add the Same Key as a Signing Key

  1. Go to GitHub: Settings β†’ SSH and GPG keys β†’ New SSH key
Field Value
Title e.g. My Laptop (Signing)
Key type Signing Key
Key Paste the same public key

βœ… You can use the same key for both authentication and signing.


Step 5 β€” Configure Git to Auto-Sign Commits

git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/id_ed25519.pub
git config --global commit.gpgsign true

Step 6 β€” Enable Vigilant Mode on GitHub

Go to GitHub: Settings β†’ SSH and GPG keys β†’ Vigilant mode

βœ… Check "Flag unsigned commits as unverified"

This ensures all commits in your repositories show a verification badge.


Step 7 β€” Verify Your Setup

git commit -m "test: signed commit"
git log --show-signature -1

Expected output:

Good "git" signature for [email protected] with ED25519 key SHA256:...

And you’ll see a βœ… Verified badge in GitHub commit history.


Quick Summary

Step Action
1 Generate SSH key with ssh-keygen
2 Add key to SSH agent
3 Add to GitHub as Authentication Key
4 Add to GitHub as Signing Key
5 Configure Git to auto-sign commits
6 Enable Vigilant Mode on GitHub
7 Test with git log --show-signature

Tips & Tricks πŸ’‘

  • Multiple machines: Repeat Steps 1–5 or securely copy your ~/.ssh/id_ed25519 key.
  • Check Git config anytime:
git config --global --list | grep -E "gpg|sign|signing"
  • View existing SSH keys before generating new ones:
ls -al ~/.ssh

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment