Skip to content

Instantly share code, notes, and snippets.

@xiaokangwang
Last active December 21, 2015 16:19
Show Gist options
  • Select an option

  • Save xiaokangwang/6332595 to your computer and use it in GitHub Desktop.

Select an option

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.
sudo apt-get install par2
openssl genrsa -out ~/BACKUPMASTERKEY.pem 8192
openssl rsa -in ~/BACKUPMASTERKEY.pem -pubout >> ~/BACKUPMASTERKEY_pub.pem
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
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_*
@xiaokangwang
Copy link
Copy Markdown
Author

Please make sure you have right to use 8192 bit rsa key before running.

@xiaokangwang
Copy link
Copy Markdown
Author

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