I would like to password protect or encrypt a directory and all the files within it (for the whole directory tree below it). I do not want to bother the whole home directory, I want a specific directory with some files and folders in it. I would like to be able to encrypt the directory or decrypt it using a password. Command line would be nicest to use. I don't want to have to create a new file as an encrypted version and then, delete the previous ones which are the non-encrypted version.
Use encfs (available as a package on most distributions). To set up:
The initial call to
In other words, for files under
When you've finished working with your files for the time being, unmount the filesystem so that the data can't be accessed until you type your passphrase again:
After that point,
When you later want to work on these files again, mount the encrypted filesystem:
This, again, makes the encrypted files in
You can change the mount point
Note that there are no "contents of a directory", a directory simply associates names with inodes, the same inodes can have lots of other names pointing at them.
What exactly are your trying to do? This is a possible solution, not a problem...
But that's exactly the scenario you've described...."be able to encrypt the directory or decrypt it"
I suspect the solution you're looking for is an encrypted FUSE or similar. The filesystem is stored in an encrypted file and when mounted (with a passphrase) there is transparent access via the VFS layer.