Skip to content

Instantly share code, notes, and snippets.

@weakish
Created July 23, 2017 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weakish/ee07e083199eecf22d4746dfd7b216ea to your computer and use it in GitHub Desktop.
Save weakish/ee07e083199eecf22d4746dfd7b216ea to your computer and use it in GitHub Desktop.
#encrypt a directory with #gnupg and #xz in #sh
#!/bin/sh
# Encrypt a directory with gnupg and xz.
#
# Usage:
#
# gpgxz dir
#
# This will tar the directory, compress it with xz,
# and sign and encrypt it with the current user's gnupg key.
# The output file will be `dir.txz.gpg` and we will list
# the contents of the output file.
#
# License: 0BSD
username="$(whoami)"
input_dir="$1"
output_file="$input_dir".txz.gpg
gpg-zip -r "$username" --tar-args cJ -o "$output_file" -s -e "$input_dir" &&
gpg-zip --list-archive "$output_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment