3

say this:

openssl enc -aes-256-cbc -e -in test.txt -out test-enc.txt

Then

rm test.txt

Then, I'd like do decrypt text-enc.txt without saving the output, just see it on a text editor (say sublime text) and then close and forget. So on my disc there's only test-enc.txt. Is it possible?

If possible, I'd like to save some aliases on my bashrc to open, modify and encrypt it again.

1
  • 1
    You might want to consider a purpose-built program for saving encrypted text (like a password manager, KeePass, etc) that won't scatter temporary files around your hard drive, and other (editing) programs that use your decrypted file might write more temporary files too, it's trivial to undelete a file that's only been rm'd, and if your swap isn't encrypted it could be another leak. And openssl's enc command might not be particularly secure on it's own Commented Sep 3, 2018 at 6:49

1 Answer 1

4

You can use /dev/shm, which is usually populated with a tmpfs which resides in memory only. Another way would be to use pipes for transferring the data from openssl ... -out /dev/stdout to the desired program using pipes and stdin.

To ensure this data is never written to disk it can be mounted with the noswap option, available since release 6.4 of the Linux kernel.

4
  • 1
    tmpfs may be written out to swap, while ramfs isn't (kernel.org/doc/Documentation/filesystems/tmpfs.txt) Commented Sep 3, 2018 at 6:56
  • Thank you for that interesting detail, which is new for me. Commented Sep 3, 2018 at 15:32
  • @xen2050 this can now be disabled, edited answer. Commented May 27, 2024 at 12:53
  • @ideasman42 That's good news! About time that swapping out a tmpfs was disabled. Your link lwn.net/Articles/925849 has some interesting info on the design decisions, although it's not necessary reading to "just use it" Commented May 27, 2024 at 20:10

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.