Skip to content

Instantly share code, notes, and snippets.

@ob1-sc
Last active June 3, 2022 15:38
Show Gist options
  • Save ob1-sc/2f2340f5f9916fb625b24c2118f6a554 to your computer and use it in GitHub Desktop.
Save ob1-sc/2f2340f5f9916fb625b24c2118f6a554 to your computer and use it in GitHub Desktop.
Setup git-crypt

install

sudo apt install git-crypt

init your git repo

cd <root of git repo>
git-crypt init

key will be generated in <root of git repo>/.git/git-crypt/keys

copy key out of repo and rename

cp <root of git repo>/.git/git-crypt/keys/default <path to store key>/<key name>

base64 encode key (to store/share)

cd <path to store key>
cat <key name> | base64 > <key name>.base64

base64 decode key (to store/share)

cd <path to store key>
cat <key name>.base64 | base64 --decode > <key name>

unlock the git repo with the key

git-crypt unlock <path to store key>/<key name>

setup .gitattributes file

# Files that are going to be encrypted
*secrets* filter=git-crypt diff=git-crypt

# Making sure that .gitattributes is never encrypted. DON'T TOUCH THAT LINE AND ONE BELOW
.gitattributes !filter !dif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment