Get the free coreGet core

GitGuardian and alternatives for finding leaked secrets

Updated 5 min readSection 05 / Threats
SHORT ANSWER

GitGuardian is a company with a hosted service for finding leaked secrets. Its command line tool, ggshield, runs on your machine or in CI and detects secrets in your code. It needs an API key to authenticate with a workspace on that service. Alternatives are GitHub secret scanning, TruffleHog and git-secrets. They differ in where they run and what they check, and the table below sets them side by side without a ranking.

People searching for this company usually want to know what it is and what else exists. Each of the four tools below solves a slightly different part of one problem: a key that ended up in code. Two of them run on your own machine, one runs on GitHub, and one lives in Git hooks, which is why the table lists where each one runs before anything else.

01What GitGuardian and ggshield are

GitGuardian runs the service: you sign in to a workspace, and ggshield authenticates against it with an API key. ggshield is the part you install. It is a CLI application, a program you run in the terminal. It runs in your local environment or in CI to help you detect leaked credentials. CI is the automatic build and test system that runs when you push code. ggshield also works as a pre-commit hook, a script Git runs before it records a commit.

The commands:

brew install ggshield
ggshield auth login
ggshield secret scan repo .
ggshield secret scan path -r .
ggshield install

brew install ggshield installs it on macOS. ggshield auth login authenticates and provisions a personal access token on the workstation. ggshield secret scan repo . scans a repository, and ggshield secret scan path -r . scans files recursively. ggshield install installs the Git hooks, so a check runs when you commit and a leaked key can be caught on your laptop, before anything is pushed.

02What data leaves your machine

Any scanner that talks to a service raises the same first worry, which is what leaves your machine. ggshield scans files through GitGuardian's public API, so the scanned content goes to the service. Only metadata such as call time, request size and scan mode is stored, and your files and secrets are not stored. Scans run from the pre-commit and pre-push hooks also send the machine hostname. The tool requires an API key to authenticate the CLI with your workspace, so you need an account to use it.

03Your first ggshield scan

The order is short. Install the tool with Homebrew. Authenticate with ggshield auth login, a command that automates the provisioning of a personal access token and its configuration on your workstation. Then, from the folder of the repository you want to check, run ggshield secret scan repo .. The dot stands for the current folder.

For a folder that is not a Git repository, use the files form, ggshield secret scan path -r .. The -r makes it recursive, which means it goes into every subfolder. If you want a check on every commit, ggshield install sets up the Git hooks.

If you would rather not create an account at all, the table below shows which tools do not ask for one. The hosted service is the part that needs it.

04Four tools side by side

ggshieldGitHub secret scanningTruffleHoggit-secrets
Where it runsYour machine, CI, pre-commitOn GitHubYour terminal, GitHub Action, pre-commitGit hooks in each repository
What it doesDetects secretsScans the entire Git history on all branchesDiscovers, classifies, validates and analyzes secretsRejects commits that match prohibited patterns
What you needA GitGuardian workspace and an API keyNothing to install; free on public repositoriesbrew install trufflehogbrew install git-secrets, then git secrets --install in every repository

05What each one is for

The table maps a need to the tools that match it. It lists features, not a verdict on which tool is better, and several of them can run side by side. Which GitGuardian alternative fits depends on where you want to scan: on your laptop before a commit, or on GitHub after a push.

If you needLook at
A check before each commit on your own machinegit-secrets, ggshield pre-commit, TruffleHog pre-commit hook
A scan of a repository's whole history on a hosted serviceGitHub secret scanning
Confirmation that a found key still worksTruffleHog or GitHub's validity checks
To scan without creating an accountTruffleHog or git-secrets, which install from Homebrew; GitHub's scanner lives inside a GitHub repository

Details: GitHub secret scanning covers setup and limits, TruffleHog has the commands, and secret scanning compares local and hosted scanning. Pick the one whose "where it runs" cell matches the moment you care about, and add a second one later if a gap shows up.

You can run more than one. A pre-commit hook can reject commits containing keys found by your scanner. GitHub's push protection adds a server-side stop: it blocks pushes that contain secrets before they reach the repository. A local hook catches the key before the push, and GitHub's scan covers what slips through. Put in order, the tools cover three moments: before the commit, as the push happens, and after the push.

06When a scanner finds a key

Whatever tool finds it, the first move is the same. If the key sat in a public repository, speed matters: automated scanners can locate publicly exposed secrets in minutes, and malicious actors can exploit them within hours. Consider the leaked key immediately compromised and revoke it with its provider. See what to do when a key leaked and a key exposed on GitHub. To scrub the history afterward, follow remove secrets from Git history. For a better home for keys, read where to store API keys.

07The short version

ggshield is one option among four. The choice depends on where you want to scan and whether an account is acceptable to you. Whichever you pick, the key still has to be revoked first.

FAQ

What is GitGuardian used for?

Finding leaked keys in code. You scan with ggshield, its command line tool, which runs in your local environment or in CI, and it authenticates against a GitGuardian workspace.

What is GitGuardian and what does it do?

It is a company that publishes ggshield and runs a service with workspaces and a dashboard. The tool detects secrets such as API keys in your code.

Is GitGuardian safe to use?

ggshield sends files to GitGuardian's API for scanning. Only metadata such as call time, request size and scan mode is stored; your files and secrets are not stored. The tool does need an API key to authenticate with a GitGuardian workspace.

What is an alternative to GitGuardian?

Three tools do related jobs: GitHub secret scanning, TruffleHog and git-secrets. The table above compares them with ggshield.

Does ggshield work on a Mac?

Yes. Install it with Homebrew: brew install ggshield.

Is there a free alternative to GitGuardian?

GitHub's scanner runs automatically for free on public repositories. TruffleHog and git-secrets install from Homebrew as command line tools.

Sources

  1. ggshield getting started
  2. ggshield README
  3. TruffleHog README
  4. git-secrets README
  5. GitHub docs, about secret scanning
  6. GitHub docs, enabling secret scanning for your repository
Scanners read your code and repos. Artificial Immunity watches program starts on the Mac where your agents work and reports what it finds.Get the free core