WARNING: Version changes in openssl may not be compatible# Data may not be recoverable without the identical version of openssl!
Add this to the bottom of ~/.profile
:
# Usage: $ encryptfile file > file.enc
function encryptfile {
openssl aes-256-cbc -a -in $1
}
# Usage: $ decryptfile file.enc > file
function decryptfile {
openssl aes-256-cbc -d -a -in $1
}
function encryptfile-ssh {
echo "Usage: $ encryptfile-ssh folder/ username@example.com"
echo "Type ctrl+c to abort, enter to continue"
read $cancel
tar -cvzf - $1 | openssl aes-256-cbc | ssh $2 "cat > file.enc"
}
function decryptfile-ssh {
echo "Usage: $ decryptfile-ssh username@example.com file"
echo "Type ctrl+c to abort, enter to continue"
read $cancel
ssh $1 "cat $2" | openssl aes-256-cbc -d | tar -xvzf -
}
Source the file:
$ . ~/.profile
Encrypt and decrypt:
$ encryptfile file.tgz > file.tgz.enc
$ decryptfile file.tgz.enc > file.tgz
$ encryptfile-ssh folder/ username@example.com
$ decryptfile-ssh username@example.com file.enc