1

I know of a method to encrypt a tar.gz archive while creating it (not sure if it's a recommend one):

tar -czvf /path/to/save/archive.tar.gz -C /path/to/archive . | 
openssl des3 -salt -k #PASSWORD# | dd of=archive

The problem is that I have some large existing archives that I'd like to encrypt also, but I'm not sure if that is possible without re-archiving everything?

1

You can encrypt any existing file with the same encryption tool and options, using standard shell redirection. For example:

openssl des3 -salt -k #PASSWORD# < oldfile.tar.gz > newfile.tar.gz

if you want to replace the old file with the new encrypted version, then:

openssl des3 -salt -k #PASSWORD# < oldfile.tar.gz > newfile.tar.gz && mv -f newfile.tar.gz oldfile.tar.gz
  • I might be trying to decrypt incorrectly, but when i use openssl des3 -d -k #PASSWORD# | tar -C tmp -xvf newfile.tar.gz there's an error: gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now error reading input file – Ned Schneebly Oct 24 '15 at 5:07
  • newfile.tar.gz needs to be read by openssl, not an arg to tar. openssl des3 -d -k #PASSWORD# < newfile.tar.gz | tar xvfz - -C tmp – cas Oct 24 '15 at 6:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.