How I hide my sensible data
Nowadays is really important for some people hide and/or protect some personal data of other people, I’ve already explained how to encrypt a LVM volume in other articles and in my first video using xvidcap
Links:
But sometimes is really pain using all of these commands to open and close my sensible data, so I made a shell script called ‘mltcrypt’ years ago to solve this:
#!/bin/bash
disk=/xdir/cryptdisk-50G.bin
rdir=/demo/.yeah
losetup="sudo /sbin/losetup"
cryptsetup="sudo /sbin/cryptsetup"
if [ "$1" = "init" ]
then
if ! mount | egrep "$rdir";
then
from="dsk$$"
if ! $losetup -a | egrep ${disk} 2&>1 >/dev/null
then $losetup /dev/loop0 ${disk}; fi
$cryptsetup luksOpen /dev/loop0 ${from}
if [ $? -ne 0 ] ; then exit; fi
sudo mount /dev/mapper/${from} $rdir
fi
cd $rdir
elif [ "$1" = "end" ]
then
if ! $losetup -a | egrep ${disk} 2&>1 >/dev/null; then exit 1; fi
dsk=`mount | grep "$rdir" | cut -d ' ' -f1 | awk -F '/' '{print $NF}'`
sudo umount -l $rdir
$cryptsetup luksClose ${dsk}
$losetup -d /dev/loop0
else
echo lol
exit 0
fi
So when I need to open my things I just type two commands
$ mltcrypt init
Will open all my data in /demo/.yeah
And to close this I just type
$ mltcrypt end
To use that you just need to change the variable values: disk and rdir.
Hope it help someone! :)