Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to encrypt a directory using gpg? It seems to only accept files as arguments.

share|improve this question
There are also ways to encrypt a whole directory or drive, but they are different in scope: they offer transparent encryption (you just type a password to mount the drive), but the result can't be read by GPG or PGP. – Gilles Jan 18 '11 at 21:21
up vote 7 down vote accepted

Why not tar the files to be encrypted and then encrypt the tarball?

share|improve this answer
I found this to be the solution. It is not flexible and requires a lot of resources to tar and gpg date. Thanks for the answer! – gladimdim Jan 20 '11 at 6:57
@gladimdim: thanks for accepting, but what do you mean by "not flexible" and "lot of resources"? Or was there a typo? – alex Jan 20 '11 at 11:59
by "not flexible" I meant that I needed manually tar directory then gpg it. I have about 60Gb of pics which are now tarballed and gpged. It took about 2 hours and 4 concurrent terminal windows to speed up this process. Now I just tarball and gpg every new directory with pics which I create. – gladimdim Jan 27 '11 at 21:51
Hm, that seems pretty reasonable time for that size of data. Did you expect to run it a lot faster? What's you plan when you need one those pics--decrypt/untar all the 60Gigs? – alex Jan 27 '11 at 22:01

I just saw the option --multifile on the manpage:

This modifies certain other commands to accept multiple files for processing on the command line or read from STDIN with each filename on a separate line. This allows for many files to be processed at once. --multi‐ file may currently be used along with --verify, --encrypt, and --decrypt. Note that --multifile --verify may not be used with detached signatures.

What you are specifically looking for is --encrypt-files and, again the manpage:

Identical to --multifile --encrypt.

share|improve this answer
Thanks, this works good except that gpg does not support --multiple key with --symmetric option (I want to encrypt only using passphrase). – gladimdim Jan 20 '11 at 6:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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