talira

git-crypt

Transparent file encryption in git

open sourceGPL-3.0-or-laterself-hostablefree

git-crypt encrypts chosen files in a Git repository when they're committed and decrypts them when they're checked out, so a repository can mix public code with secrets such as keys and credentials. You mark files to encrypt with patterns in .gitattributes, and share access by adding collaborators' GPG keys (git-crypt add-gpg-user, which commits an encrypted key file) or by exporting a symmetric key. Files are encrypted with AES-256 in CTR mode with a synthetic IV, so the encryption is deterministic and git can still tell when a file changed; people without the key can still clone and commit. Andrew Ayer wrote it, under GPL-3.0 or later; compare SOPS, which encrypts values inside a file.

Ways to install

Problems it solves

  • keep a few secret files encrypted inside an otherwise public git repository
  • commit API credentials and private keys to the repo without anyone who clones it being able to read them
  • files decrypt automatically on checkout for teammates who have the key, without extra commands each time
  • share access to encrypted files in a repo with my team's GPG keys
  • developers without the secret key can still clone the repo and commit to it
  • encrypt *.key files and a secrets directory in git by pattern, like a .gitignore for encryption
  • unlock an encrypted repository in CI with a symmetric key file
  • store infrastructure secrets in the same repository as the code that deploys them

Features

  • transparent encryption on commit and decryption on checkout through git filters
  • choose files with .gitattributes patterns (filter=git-crypt diff=git-crypt)
  • multi-user access with GPG keys: git-crypt add-gpg-user commits a GPG-encrypted key file
  • symmetric key mode: git-crypt export-key and git-crypt unlock /path/to/key, no GPG needed
  • git-crypt lock to re-encrypt a working copy
  • AES-256 in CTR mode with a synthetic IV from an HMAC-SHA1 of the file: deterministic but semantically secure
  • degrades gracefully: people without the key can clone and commit

Limitations

  • Doesn't encrypt file names, commit messages or other metadata: only file contents are encrypted3
  • No way to revoke access or rotate keys: there's no command to remove a GPG user, and the symmetric key can't be rotated3
  • Not suited to encrypting a whole repository: the README recommends git-remote-gcrypt for that3
  • Encrypted files aren't stored as deltas: every change stores the whole encrypted file again3
  • Windows support is experimental: build it yourself with MinGW, and key files don't get restrictive permissions4

Capabilities

Has a command line toolplan not known

Alternatives

The same job

These do what git-crypt does.

  1. Sealed Secrets A Kubernetes controller and tool for one-way encrypted Secrets
  2. dotenvx A secure dotenv, from the creator of dotenv
  3. SOPS Simple and flexible tool for managing secrets

Compare git-crypt with the top 3