Encryption using tar bzip gzip and zip
Hi
can any one tell me if i can encrypt a file using tar or tar bzip/gzip or zip command while taking a backup just as i can do with vi |
you can tar something, encrypt it then compress it using bzip/gzip, or tar something, compress it and encrypt it. According to the tar manpage, it is not supported directly, but based on the way tar and gz/bz2 work, it is simply an other layer in between. You are free to use one of many crypt tools available.
|
Encrypted data should not have any discernible patterns so should not compress well. If that theory is correct, compression followed by encryption should produce a smaller file than encryption followed by compression.
|
Quote:
You may want to do this--- Code:
tar czf foo.tar.gz foo.txt && gpg -c foo.tar.gz You may remove the original file or delete them after gpg encrypted file is made. Or include deletion within command: Code:
tar czf foo.tar.gz foo.txt && gpg -c foo.tar.gz && rm -f foo.txt From thence you may create a script to be envoked when encrypting file. Hope that helps. Good luck. |
tar cf - /path/to/data | 7z a -si archivename.tar.7z
http://www.commandlinefu.com/command...7z-compression The post also has some additions useful. "What others think some newer versions of tar support the '--lzma' option LZMA is the same type of compression used by 7zip This is a cleaner option, though I suppose it is only supported by newer versions of tar which could be a problem... tar c --lzma /path/to/data > archivename.tar.lzma Comment by infinull 174 weeks and 4 days ago According to google, GNU tar supports the lzma option since tar 1.20. Starting in tar 1.22 -J (capital 'j') means --xz and not --lzma. Comment by bwoodacre 174 weeks and 3 days ago " |
Thank you jefro. I did not know that.
My tar version=1.26 the --lzma and -J options are already available. I have tried tarring with lzma, the resulting file cannot be stat by 'fileroller' while the resultant file of -J option is easily handled by the same GUI reader. Both results extracted by the same switch. I observe that --lzma switch is entered only after the file name tar -cf foo.tar.lz foo --lzma. Thank you again. |
I learn something new everyday here.
|
tar the file first like you normally would
Code:
tar cvjf /path/to/tarball.tar.bz2 -X /path/to/excludes.conf /path/of/file/directory/to/tar to encrypt you can use something as simple as this: Code:
openssl des3 -a -salt -in /path/to/tarball.tar.bz2 -out /path/to/target/encrypted/tarball.tar.bz2.enc -pass pass:<password_here> you can also use && to combine that into one command line. so it will first make the tarball, then encrypt it. Code:
tar cvjf /path/to/tarball.tar.bz2 -X /path/to/excludes.conf /path/of/file/directory/to/tar[ && openssl des3 -a -salt -in /path/to/tarball.tar.bz2 -out /path/to/target/encrypted/tarball.tar.bz2.enc -pass pass:<password_here> |
All times are GMT -5. The time now is 06:16 AM. |