Article 5MF0A advise for secure removal of keyfile

advise for secure removal of keyfile

by
slac-in-the-box
from LinuxQuestions.org on (#5MF0A)
Howdy slackers:

I am automating luks+lvm installing.

My script prompts me for passkey, saves the key to a file, and then uses cryptsetup with the --key-file option

After setup, I would like the script to remove this temporary keyfile such that recovery or forensics software would not be able to retrieve it.

At slackbuilds, there is srm and wipe. srm says it doesn't work with journaled file systems, and I use ext4. wipe has not seen an update in over seven years... but maybe it doesn't need one.

So without using either, my strategy is as follows:
  1. use "dd if=/dev/zero of=keyfile.img bs=512 count=8" to create a 4kb blank image
  2. use "mkfs.ext4 keyfile.img" to format the image with a file system
  3. use "mount keyfile.img /mnt/tmp" to mount the filesystem
  4. let the script write the passkey to /mnt/tmp/keyfile
  5. once the script is done with the keyfile, I thought I could
  6. use "umount /mnt/tmp" to unmount the image
  7. use "dd if=/dev/urandom of=keyfile.img bs=512 count=8" to write random data over the image (maybe four times even)
  8. use "rm keyfile.img" to delete the image.
To my thinking, that would do it without installing 3rd party packages.

Are there any flaws with this strategy?latest?d=yIl2AUoC8zA latest?i=MOaxzfKBHIM:pkLH8XOtwXU:F7zBnMy latest?i=MOaxzfKBHIM:pkLH8XOtwXU:V_sGLiP latest?d=qj6IDK7rITs latest?i=MOaxzfKBHIM:pkLH8XOtwXU:gIN9vFwMOaxzfKBHIM
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments