I have a command (ansible-vault decrypt
) that decrypts a file and writes it out. I can write it out to a file or to -
/stdout
.
I would then like to use this decrypted file (a private key) with another command that expects an argument like mycommand --key-file <path to file>
.
My current script runs ansible-vault decrypt --output mykey.key
to write the decrypted file to disk, then mycommand --key-file mykey.key
, and finally deleting it with rm mykey.key
.
Is there a way to somehow not write the decrypted file to disk at all, and still have mycommand
be able to access it as if it was a file?
I can't pipe to the second command, because it doesn't read the key from stdin at all. The only thing I could think of is to create a ramdisk before running the commands, writing the key there, and unmounting the ramdisk once all commands have run which (I think) would make the decrypted key disappear without a trace.
ansible-vault decrypt
command write to standard output or does it require a file? – terdon May 27 '20 at 18:26tmpfs
) are run in RAM ... and SWAP - which might be your problem. Nevertheless, read permissions work the same as on the hard disk, so I feel like you want to target a security problem in the wrong manner. What is your target and what do you fear? – FelixJN May 27 '20 at 18:27shred
it first. Otherwise it can still be recovered from the HD – IanC May 27 '20 at 18:31