I am having trouble finding an answer to a question about protecting unencrypted data. I run Ubuntu 12.04. Although I'm not sure that it's relevant, I'll also mention that I use an encrypted home directory (and thus also have encrypted Swap space) but do not use full-disk encryption. My hard drive is formatted with ext4.
I have a text file that contains some application passwords. I keep this file encrypted using GPG. Whenever I want to edit the passwords in the file, I use GPG to write the decrypted contents to disk, edit the text in my favourite text editor (currently, Gedit), have GPG re-encrypt the file, and then rm
the unencrypted version.
Recently, I've realized that in being written to disk, the unencrypted text could possibly be read from the disk itself if it's not overwritten. I realize that shred
really doesn't work for this purpose with a journaling filesystem like ext4. I read at https://stackoverflow.com/a/12289967 that it's possible to write the unencrypted file to a tmpfs -- i.e., directly to RAM or Swap space. The post that I linked to suggests using /dev/shm; however, my understanding is that that directory is intended to be used for shared memory operations, and has also been deprecated in favor of /run/shm. It sounds like writing to /run might be a better idea, then.
If I were to write the decrypted file to /run (or, for that matter, to /dev/shm), would there be any adverse consequences? Would the file be protected more than if it were written straight to disk (like I've been doing)? Is writing to those directories a bad idea for reasons I don't even know to think of?
I'll be very grateful for any advice that you can offer. Thank you!