From 34ae748408bda90c629889ec226a4097f144ff27 Mon Sep 17 00:00:00 2001 From: Espen Henriksen Date: Tue, 19 Apr 2016 21:06:35 +0200 Subject: [PATCH 1/2] #7 Add support for asymmetric encryption --- yadm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/yadm b/yadm index 429f3d3..40718d6 100755 --- a/yadm +++ b/yadm @@ -223,8 +223,16 @@ function encrypt() { #; process relative to YADM_WORK YADM_WORK=$(git config core.worktree) + GPG_KEY="$(config yadm.gpg-recipient)" cd $YADM_WORK + #; Build gpg options for gpg + if [ "$GPG_KEY" != "" ]; then + GPG_OPTS="-er $GPG_KEY" + else + GPG_OPTS="-c" + fi + #; build a list of globs from YADM_ENCRYPT GLOBS=() while IFS='' read -r glob || [ -n "$glob" ]; do @@ -234,7 +242,7 @@ function encrypt() { done < "$YADM_ENCRYPT" #; encrypt all files which match the globs - tar -cv ${GLOBS[@]} | gpg --yes -c --output "$YADM_ARCHIVE" + tar -cv ${GLOBS[@]} | gpg --yes "$GPG_OPTS" --output "$YADM_ARCHIVE" if [ $? = 0 ]; then echo "Wrote new file: $YADM_ARCHIVE" else From 33c8cd8a2176dad3b3d597217126f34174aa60ce Mon Sep 17 00:00:00 2001 From: Espen Henriksen Date: Tue, 19 Apr 2016 21:56:00 +0200 Subject: [PATCH 2/2] #7 Document gpg-recipient --- yadm.1 | 6 ++++++ yadm.md | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/yadm.1 b/yadm.1 index b369aaa..5bf1f35 100644 --- a/yadm.1 +++ b/yadm.1 @@ -248,6 +248,12 @@ This feature is enabled by default. Disable the permission changes to .IR $HOME/.gnupg/* . This feature is enabled by default. +.TP +.B yadm.gpg-recipient +Asymmetrically encrypt files with a gpg public/private key pair. +Provide a key ID to encrypt against that public key. +If left blank or not provided, symmetric encryption is used instead. +This feature is disabled by deafult. .SH ALTERNATES When managing a set of files across different systems, it can be useful to have an automated way of choosing an alternate version of a file for a different diff --git a/yadm.md b/yadm.md index 7d8a1bd..0a2ab22 100644 --- a/yadm.md +++ b/yadm.md @@ -150,6 +150,12 @@ Disable the permission changes to $HOME/.gnupg/*. This feature is enabled by default. + yadm.gpg-recipient + Asymmetrically encrypt files with a gpg public/private key pair. + Provice a key ID to encrypt against that public key. + If left blank or not provided, symmetric encryption is used + instead. This feature is disabled by deafult. + ## ALTERNATES When managing a set of files across different systems, it can be useful to have an automated way of choosing an alternate version of a file for