2

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 Answer 1

2

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
3
  • 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 Commented Oct 24, 2015 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
    Commented Oct 24, 2015 at 6:41
  • if you are seeing a warning, check this out: askubuntu.com/questions/1093591/…
    – brad
    Commented Jun 27, 2022 at 19:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .