7.18. Encrypting Directories

Problem

You want to encrypt an entire directory tree.

Solution

To produce a single encrypted file containing all files in the directory, with symmetric encryption:

$ tar cf - name_of_directory | gpg -c > files.tar.gpg

or key-based encryption:

$ tar cf - name_of_directory | gpg -e > files.tar.gpg

To encrypt each file separately:

$ find name_of_directory -type f -exec gpg -e '{}' ;

Discussion

Notice the find method uses public-key encryption, not symmetric. If you need a symmetric cipher [Recipe 7.4] or to sign the files [Recipe 7.13], avoid this method, as you’d be prompted for your password/passphrase for each file processed.

See Also

gpg(1), find(1), tar(1).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.37.161