Last active
December 21, 2015 16:19
-
-
Save xiaokangwang/6332595 to your computer and use it in GitHub Desktop.
shell script to make a file secured and ready for upload for web UI.
This file contains hidden or 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
sudo apt-get install par2 | |
openssl genrsa -out ~/BACKUPMASTERKEY.pem 8192 | |
openssl rsa -in ~/BACKUPMASTERKEY.pem -pubout >> ~/BACKUPMASTERKEY_pub.pem |
This file contains hidden or 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
openssl rand -out /tmp/kkbackup.bin 512 | |
openssl rsautl -encrypt -pubin -inkey ~/BACKUPMASTERKEY_pub.pem -in /tmp/kkbackup.bin -out file.secured | |
openssl enc -aes-256-xts -salt -in backup.7z -out file.bin -pass file:/tmp/kkbackup.bin | |
rm /tmp/kkbackup.bin | |
echo "=========================" | |
sha1sum file.bin | |
echo "=========================" | |
rm backup.7z | |
split -b 50M file.bin file.bin.parts_ | |
rm file.bin | |
par2create -r20 -l file.bin.rep file.bin.parts_* file.secured |
This file contains hidden or 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
par2repair file.bin.rep file.bin.parts_* file.secured | |
rm *.1 | |
cat file.bin.parts_* >> file.bin | |
openssl rsautl -inkey ~/BACKUPMASTERKEY.pem -decrypt -out /tmp/kkbackup.bin -in file.secured | |
openssl enc -d -aes-256-xts -salt -in file.bin -out backup.7z -pass file:/tmp/kkbackup.bin | |
rm /tmp/kkbackup.bin | |
echo "=========================" | |
sha1sum file.bin | |
echo "=========================" | |
rm file.bin | |
rm file.bin.parts_* |
backup.7z is the file will be progressed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please make sure you have right to use 8192 bit rsa key before running.