GithubHelp home page GithubHelp logo

backwardn / git-remote-grave Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rovaughn/git-remote-grave

0.0 2.0 0.0 48 KB

Git remote helper for encrypted repositories with NaCl.

License: MIT License

Go 99.48% Shell 0.52%

git-remote-grave's Introduction

git-remote-grave

Adds a protocol to git for pushing and fetching encrypted repositories.

Example with a local file:

$ git remote add backup grave::/mnt/external-disk/backup
$ git push --all backup
git fast-import...
git repack -a -d -f...
git gc...
Packing and compressing...
Encrypting...
Pushing...
To grave::/mtn/external-disk/backup
 * [new branch]      master -> master
$ git fetch backup

Example with HTTP:

$ git clone grave::https://example.com/username/private-repo
Cloning into 'private-repo'...
Checking connectivity... done.

How do you make something like this?

I did a write-up here.

Using a key

The encryption key is produced by taking the SHA256 hash of a keysource. The keysource can be of any length; leading and trailing whitespace is stripped so that trailing newlines are not an issue.

If a key has not been set for the repository, then git-remote-grave will interactively determine the key. In all cases, the keysource will be ultimately copied to .git/grave/remotename/key with 600 permissions.

Three options are provided:

  1. Enter the keysource by typing a string. The characters will not be echoed, like a password.
  2. Specify an existing file as the keysource.
  3. Randomly generate a new key. Most secure. Only when pushing.

You can also set the environment variable GRAVE_KEYFILE to a file to use as the keysource. This may be useful in scripts.

Encryption

The package golang.org/x/crypto/nacl/secretbox, which is a port of DJB's NaCl, is used to encrypt and authenticate repositories. The nonce is randomly generated every time the repository is encrypted, so that two identical repositories encrypt to two completely different blobs of data. However, git-remote-grave knows if the unencrypted repository actually changed, and will skip a push or fetch if it's unecessary.

Packing and compression

After creating an encrypted repository for the first time, git repack -a -d -f and git gc are run. All the times after that, just git repack and git gc are run.

The repository is then packed with tar and compressed.

A tar archive of an empty git repository is used as the dictionary in the compression, improving the ratio. The algorithm used is golang's DEFLATE library on maximum compression level.

The combination of these techniques typically reduces the repository size by 78%.

git-remote-grave's People

Contributors

rovaughn avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.