LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   disable echoing password in etc/init.d encryption boot script (https://www.linuxquestions.org/questions/linux-security-4/disable-echoing-password-in-etc-init-d-encryption-boot-script-678523/)

tatanna 10-23-2008 06:57 AM

disable echoing password in etc/init.d encryption boot script
 
Hello I have this working script in /etc/init.d/

Code:

#!/bin/sh
NAME=mount_raid
DESC="Mount RAID encrypted volume"

mount_raid() {
        echo "Unlocking /dev/md0"
        stty -echo
        cryptsetup luksOpen /dev/md0 raid_data
        stty echo
        echo "Scanning for volume groups"
        vgscan --mknodes
        vgchange -ay
        echo "Mounting /media/raid_data/"
        mount /dev/mapper/raid_data_vol-raid_data /media/raid_data/
}

umount_raid() {
        echo "Un-mounting /media/raid_data/"
        umount /media/raid_data/
        # Mark the logical volume INACTIVE (can be restored with 'lvchange -ay')
        lvchange -an raid_data_vol
        # Mark the volume group INACTIVE (can be restored with 'vgchange -ay')
        vgchange -an raid_data_vol
        echo "Re-locking /dev/md0"
        cryptsetup remove raid_data
}


case "$1" in
  start)
        mount_raid
        ;;
  stop)
        umount_raid
        ;;
  *)
        N=/etc/init.d/$NAME
        # echo "Usage: $N {start|stop}" >&2
        echo "Usage: $N {start|stop}" >&2
        exit 1
        ;;
esac

exit 0

How do I disable echoing of the password when I input it during the boot process?

as you can see I tried with the option "stty -echo" but doesn't seem to work.. any idea?

thanks

plpl303 10-24-2008 08:47 PM

I've never worked with cryptsetup -- but I'm surprised it echoes the passphrase.

Maybe something like this will do what you want:

Code:

read -s -p "Enter password: " mypass
echo $mypass | cryptsetup luksOpen /dev/md0 raid_data


I haven't tried it, but just from eyeballing, it looks like it should (might ;-) work.

tatanna 10-25-2008 06:15 PM

Hey thanks, the option -s wasn't supported in my bash shell.
However you prompted me the right way... below is what finally worked

Code:

stty -echo
read  -p "Enter password: " mypass
stty echo
echo $mypass | cryptsetup luksOpen /dev/md0 raid_data

thank you veyr much

tatanna 11-13-2008 05:03 AM

counter-order.. the above works in a shell but not during boot up!
what's the difference in the echoing between boot up scripts and userspace shell scripts??
why does it work only in the second??? really can't help myself!


All times are GMT -5. The time now is 11:39 PM.