git-secure-export

Experimental tooling for encrypting the git-fast-export(1) output

git clone https://git.8pit.net/git-secure-export.git

 1#!/bin/sh
 2# Git remote helper for git-secure-export, see gitremote-helpers(7).
 3
 4if [ ! -e "$GIT_DIR/git-secure-key" ]; then
 5	cat 1>&2 <<-EOF
 6		*
 7		* The symmetric key, needed for decrypting the repository, does
 8		* not exist yet. If you are creating a new repository this key
 9		* must be created explicitly using git-secure-init.
10		*
11		* If you are attempting to clone an existing repository and have
12		* access to the utilized symmetric key perform the following steps:
13		*
14		*  1. Manually initialize the repository using git-init(1).
15		*  2. Copy the symmetric key to the .git/ directory.
16		*  3. Add the secure:// remote manually and pull/fetch.
17		*
18EOF
19	exit 1
20fi
21
22# From gitremote-helpers(7):
23#  The second argument specifies a URL; it is usually of the form
24#  <transport>://<address>, but any arbitrary string is possible.
25URL="$2"
26
27get_host() {
28	echo "$URL" | sed 's|^..*://\(..*\):.*|\1|'
29}
30
31get_path() {
32	echo "$URL" | sed 's|^..*://..*:\(.*\)|\1|'
33}
34
35# git-secure-import only encrypts data as specified in the INPUT
36# FORMAT section of git-fast-import(1). Similarly, git-secure-import
37# only decrypt data matching this format. All other data is simply
38# copied from standard input to standard output.
39git-secure-export | \
40	ssh "$(get_host)" "git-secure-receive $(get_path)" | \
41	git-secure-import