Created
July 15, 2019 14:50
-
-
Save afk11/c214ab68de3c1fdaf204e117692fa42e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# takes a file path (Dir or file) to tar, | |
# and a second argument, the prefix of the generated key & tarball. | |
# PUBKEY_FILE is hardcoded, should be changed | |
if [ $1 = "" ]; then | |
echo "filepath is required" | |
exit -1; | |
fi | |
if [ $2 == "" ]; then | |
echo "name is required" | |
exit -1; | |
fi | |
PATH=$1 | |
NAME=$2 | |
PUBKEY_FILE=/publickey.pem | |
echo "openssl rand -base64 32 > ${NAME}.key" | |
echo "openssl rsautl -encrypt -pubin -inkey ${PUBKEY_FILE} -in ${NAME}.key -out ${NAME}.key.enc" | |
echo "tar -czf - ${PATH} | /usr/bin/openssl enc -aes-256-cbc -salt -out ${NAME}.tar.gz.enc -pass file:./${NAME}.key" | |
echo "mv ${NAME}.tar.gz.enc pub/" | |
echo "mv ${NAME}.key.enc pub/" | |
echo "srm ${NAME}.key" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment