Sign Commits with GPG and SSH for Supply-Chain Trust

Khimananda Oli 8 min read Virtualization
Sign Commits with GPG and SSH for Supply-Chain Trust

By Khimananda Oli | Last reviewed: August 2026

Software supply chain attacks have shifted from compromising build servers to impersonating maintainers via unsigned or forged commits. To prevent this, you must sign commits with GPG and SSH for supply-chain trust, creating a cryptographic link between code changes and verified identities. This practice ensures that every merge request and release tag can be mathematically attributed to an authorized developer, forming the bedrock of audit-ready infrastructure and compliance frameworks like SOC 2.

Developer LocalGit Remote / VCSCI / Audit LogSigned CommitVerify SigGPG / SSH Key
High-level flow: developers sign commits with GPG and SSH for supply-chain trust before pushing to remote repositories where CI verifies authenticity.

Why should you sign commits with GPG and SSH for supply-chain trust?

Identity spoofing remains one of the most persistent vectors in software supply chain compromises. An attacker who gains write access to a repository can craft commits with arbitrary author metadata, making malicious code appear to originate from a trusted maintainer. Cryptographic signing eliminates this ambiguity by binding each commit to a private key that only the legitimate owner possesses.

Beyond security, regulatory and customer-driven compliance increasingly demands provenance. During SOC 2 Type II audits, I frequently encounter findings related to "unverified code changes." Auditors want evidence that production deployments trace back to approved, authenticated sources. When you implement CI/CD best practices alongside mandatory signing, you create an immutable chain of custody. This satisfies control objectives around change management and logical access without adding manual approval bottlenecks.

For teams operating in regulated environments or handling sensitive data, unsigned commits represent an unacceptable risk surface. The cost of implementing signing is negligible compared to the forensic effort required to investigate a compromised repository or explain unverified changes during a compliance review.

How do you configure Git to sign commits with GPG and SSH keys?

Modern Git supports both GPG and SSH as signing formats. While GPG has been the historical standard, SSH signing (available since Git 2.34) allows you to reuse existing authentication keys, reducing key management overhead. However, GPG retains advantages for cross-platform identity certification and integration with hardware tokens.

Generating an ED25519 signing key

For new deployments in 2026, ED25519 is the recommended algorithm due to its speed and compact signatures. Avoid RSA keys shorter than 4096 bits and deprecated SHA-1 hashes.

# Generate an ED25519 SSH key specifically for signing
ssh-keygen -t ed25519 -C "[email protected]" -f ~/.ssh/git_signing_key

# Or generate a GPG key with modern defaults
gpg --full-generate-key --pinentry-mode loopback
# Select: (1) RSA and ECC → (9) ECC (sign only) → Curve 25519
# Set expiration to 2y maximum for rotation hygiene

Configuring Git globally or per-repository

Once generated, register the key with Git. For SSH signing, use the public key path; for GPG, use the key fingerprint.

# SSH signing configuration
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/git_signing_key.pub
git config --global commit.gpgsign true

# GPG signing configuration (alternative)
git config --global gpg.format openpgp
git config --global user.signingkey FINGERPRINT_HERE
git config --global commit.gpgsign true

A common mistake is forgetting to add the public key to your hosting platform. GitHub, GitLab, and Bitbucket all require you to upload the signing public key separately from your authentication key. Without this step, commits will be signed locally but show as "Unverified" on the web interface, defeating the purpose of establishing trust.

GPG vs SSH signing: Which method fits your security model?

Choosing between GPG and SSH depends on your team's operational maturity, compliance requirements, and existing infrastructure. Both achieve the core goal when you manage keys securely, but they differ significantly in administration overhead and ecosystem support.

CriteriaGPG SigningSSH Signing
Key ManagementSeparate keyring; requires gpg-agentReuses existing SSH keys; simpler
Hardware Token SupportMature (YubiKey, Nitrokey)Limited; emerging in 2026
Identity AttestationWeb of Trust / CA signaturesTied to hosting platform account
Cross-Platform ToolingRequires GnuPG installationNative OpenSSH everywhere
Audit & ComplianceStronger non-repudiation evidenceSufficient for most SOC 2 controls
Rotation ComplexityHigher; subkeys help mitigateLower; standard SSH rotation

In my practice, I recommend SSH signing for internal engineering teams prioritizing velocity and low friction. Reserve GPG for release managers, open-source maintainers, or environments requiring hardware-backed non-repudiation. If your organization already uses HashiCorp Vault for secrets management, consider integrating it with GPG agent forwarding to centralize key operations without exposing private material to developer workstations.

Start: Need Signing?Hardware Token Required?YesNoUse GPG + YubiKeyUse SSH SigningBest for ReleasesBest for Daily Dev
Decision tree helping teams choose the right method when they sign commits with GPG and SSH for supply-chain trust based on hardware and compliance needs.

How do you automate signature verification in CI pipelines?

Signing alone does not guarantee trust; you must verify signatures at enforcement points. A signed commit pushed to a repository that accepts unsigned merges provides false assurance. In 2026, effective supply-chain security requires automated verification gates in your CI system and branch protection rules.

  1. Enable branch protection: Configure your VCS to require signed commits on protected branches (main, release/*). Reject pushes that lack valid signatures.
  2. Add CI verification jobs: Even with branch protection, run explicit verification in pipelines to generate audit artifacts. Use git log --show-signature or dedicated tools like sigstore/gitsign for structured output.
  3. Fail fast on invalid signatures: Treat missing or expired signatures as pipeline failures, not warnings. This prevents drift where developers bypass signing during emergencies.
  4. Log verification results: Store signature metadata (key ID, timestamp, signer email) in your centralized logging system. This creates the evidence trail auditors expect.
# Example GitLab CI job for signature verification
verify-signatures:
  stage: validate
  script:
    - apk add --no-cache gnupg openssh-client
    - git fetch --unshallow
    - |
      INVALID=$(git log origin/main..HEAD --format="%H %G?" | grep -v "G$" || true)
      if [ -n "$INVALID" ]; then
        echo "::error::Unsigned or invalid commits detected:"
        echo "$INVALID"
        exit 1
      fi
  allow_failure: false

This approach aligns with infrastructure-as-code principles where policy is codified rather than enforced through tribal knowledge. When verification is part of the pipeline definition, it survives team turnover and scales across repositories.

What are the operational pitfalls when managing signing keys?

The most frequent failure mode I observe is not technical misconfiguration but operational neglect. Keys expire, developers leave, laptops fail, and suddenly teams cannot sign releases or verify historical commits. Proactive lifecycle management prevents these outages.

Key expiration and rotation: Set reasonable expiration dates (1–2 years) and establish rotation procedures well before expiry. For GPG, use subkeys for signing while keeping the master key offline. This limits blast radius if a signing key is compromised. Document the rotation runbook and test it quarterly.

Revocation planning: Generate revocation certificates immediately after key creation and store them securely offline. If a developer departs unexpectedly or a device is lost, you must be able to revoke the key within hours, not days. Integrate revocation checks into your offboarding checklist.

Local agent configuration: Developers often struggle with GPG agent timeouts or pinentry programs failing in headless environments. Standardize agent configuration across the team using dotfiles or configuration management. For SSH signing, ensure ssh-add includes the signing key in CI runners and developer machines alike.

Backup without exposure: Never back up private signing keys to cloud storage unencrypted. Use encrypted USB drives or hardware security modules for backups. The goal is recovery capability without expanding the attack surface. If you cannot recover a key securely, accept that you will need to rotate and re-sign critical tags.

Generate KeyActive SigningRotate / ExtendRevoke / ArchiveBack to ActiveCompromised?Immediate Revoke
Key lifecycle stages ensuring continuous ability to sign commits with GPG and SSH for supply-chain trust without operational gaps.

Establishing Verified Trust Across Your Engineering Organization

Implementing cryptographic signing is a foundational step toward a verifiable software supply chain, but technology alone does not sustain trust. Success requires embedding these practices into onboarding, code review culture, and compliance documentation. Start with a pilot team, refine your key distribution and verification automation, then expand with documented standards. Monitor adoption metrics and treat unsigned commits as incidents until the behavior is universal.

If your team needs guidance on integrating commit signing into existing CI/CD workflows, preparing for SOC 2 audits, or designing a key management strategy that balances security with developer experience, reach out to discuss your specific infrastructure challenges. Building supply-chain trust is an investment that compounds over time — start signing today so your future self isn't explaining unverified commits to an auditor tomorrow.

Frequently Asked Questions

Signing cryptographically proves authorship and prevents tampering. Platforms like GitHub verify signatures to display "Verified" badges, ensuring downstream consumers trust the code origin. This mitigates impersonation attacks and strengthens software supply chain integrity across CI/CD pipelines and release artifacts in 2026.

Yes. Git 2.34+ supports SSH signing natively. Configure gpg.format to ssh and set user.signingkey to your public SSH key path. This eliminates separate GPG key management while providing equivalent cryptographic verification for supply-chain trust without additional tooling overhead.

Both work; choice depends on workflow. SSH is simpler if you already use SSH keys for authentication. GPG offers broader ecosystem support and hardware token integration. For new projects prioritizing developer experience, SSH reduces friction while maintaining equivalent supply-chain verification standards.

Run git config --global commit.gpgsign true and set your signing key via user.signingkey. For SSH, also set gpg.format ssh. This ensures every local commit is signed without manual flags, enforcing consistent supply-chain provenance across all repositories.

Immediately revoke the key on your platform and generate a new one. Past signed commits remain valid but untrusted after revocation. Rotate credentials, audit recent activity, and consider re-signing critical release tags. Document the incident to maintain transparent supply-chain accountability.

Negligibly. Signing adds milliseconds per commit locally. Verification during push or fetch may add slight latency depending on platform load. Modern hardware and optimized crypto libraries make performance impact imperceptible for typical development workflows in 2026 environments.

Yes. Use git log --show-signature or platform APIs to validate signatures in pipeline gates. Fail builds on unverified commits to enforce policy. Tools like Sigstore or SLSA frameworks integrate signature checks into automated release validation for end-to-end supply-chain assurance.

Generate an SSH key, update Git config, and add the new key to your platform profile. Old GPG-signed commits retain verification if the key remains valid. Announce the transition to collaborators and update documentation to reflect the new signing method for continuity.

No direct costs. GPG and SSH are open standards. Hardware tokens like YubiKeys cost $50-$100 each for enhanced security. Platform verification is free on GitHub, GitLab, and Bitbucket. Budget only for optional hardware or enterprise key management services if required.

Check gpg.program path, ensure agent is running with gpgconf --kill gpg-agent, and verify key isn’t expired. Test signing manually with echo test | gpg --clearsign. On macOS, install pinentry-mac. Confirm Git config matches actual key ID format exactly.

Technically yes via git filter-repo, but it rewrites history and breaks clones. Only attempt for unpublished branches. For public repos, accept historical gaps and enforce signing going forward. Retroactive signing risks collaboration disruption outweighing marginal supply-chain benefits.

Not directly. Signing verifies authorship, not branch immutability. Combine with branch protection rules requiring signed commits and disabling force pushes. Signed tags on releases provide stronger tamper evidence than individual commits alone for comprehensive supply-chain defense.

Verified commits show green checkmarks or badges. Unverified appear neutral or warn if previously verified keys were revoked. Unsigned commits lack indicators entirely. These visual cues help reviewers and automated tools quickly assess trustworthiness during code review and dependency evaluation.

Yes. Separate keys isolate risk and simplify revocation. Work keys can be managed via corporate PKI or rotated per employment changes. Personal keys remain under individual control. Distinct identities prevent cross-contamination and clarify attribution in multi-account supply-chain scenarios.

The signature binds commit hash, author, timestamp, and message into a cryptographic blob. Verifiers confirm this bundle hasn’t been altered since signing. Metadata itself isn’t encrypted; signing provides integrity and authenticity, not confidentiality, which aligns with supply-chain transparency requirements.