LUKSシステムのロックを解除するために起動時にUSBキーがインストールされていません。

LUKSシステムのロックを解除するために起動時にUSBキーがインストールされていません。

私はDebian Jessieを使用しています。ハードドライブが2つあり、各パーティションが2つのハードドライブ(RAIDではなく)に分散されています。それらはすべてLVMを使用して個別にLUKS暗号化を実行します。私の/bootパーティションは、2つのハードドライブに含まれていない唯一のパーティションです。代わりに、暗号化されていないUSBスティックにあります。どちらのハードドライブも/bootパーティションからロック解除する必要がありますmyKeyfile.key(ただしそうではありません)。私の目標は、USBスティックなしでシステムを起動したときにディスクに完全にアクセスできない、または役に立たないようにすることです。

これを達成するために私がしたことは次のとおりです。使ったこの回答StackOverflowをガイドとして使用してください。


/etc/default/cryptdisks

# Mountpoints to mount, before cryptsetup is invoked at initscripts. Takes
# mountpoints which are configured in /etc/fstab/ as arguments. Separate
# mountpoints by space.  

# original: CRYPTDISKS_MOUNT=""
CRYPTDISKS_MOUNT=/boot

コメントに基づいてで述べたように、マウントポイント名が正しいことを確認してくださいfstab。完全性のために、関連する行は次のとおりです。

/etc/fstab

# <file system> <mount point> <type> <options> <dump> <pass>
 UUID=<usb uuid>    /boot      ext4   defaults    0     2

/etc/crypttab

sda1_crypt  UUID=<disk uuid>  /boot/myKeyfile.key  luks,keyscript=/bin/passphrase-from-usb
sda2_crypt  UUID=<disk uuid>  /boot/myKeyfile.key  luks,keyscript=/bin/passphrase-from-usb

USBドライブのUUID(代わりに)を指定できますが、興味のあるファイルを/boot/myKeyfile.key指定する方法がわかりません。myKeyfile.key

/etc/initramfs-tools/hooks/passphrase-from-usb

#!/bin/sh

PREREQ=""

prereqs() {
        echo "$PREREQ"
}

case "$1" in
        prereqs)
                prereqs
                exit 0
       ;;
esac

. "${CONFDIR}/initramfs.conf"
. /usr/share/initramfs-tools/hook-functions

copy_exec /bin/passphrase-from-usb /bin

/bin/passphrase-from-usb

#!/bin/sh

set -e

    if ! [ -e "$CRYPTTAB_KEY" ]; then
        echo "Waiting for USB stick to be recognized..." >&2
        sleep 5
    fi
    if [ -e "$CRYPTTAB_KEY" ]; then
        echo "Unlocking the disk $CRYPTTAB_SOURCE ($CRYPTTAB_NAME) from USB key" >&2
        echo "Using $CRYPTTAB_KEY as the key source" >&2
        dd if="$CRYPTTAB_KEY" bs=1 count=256 2>/dev/null
        exit
    else
        echo "Can't find $CRYPTTAB_KEY; USB stick not present." >&2
    fi

/lib/cryptsetup/askpass "Manually unlock the disk ($CRYPTTAB_NAME)\nEnter passphrase: "


起動時に受け取るウェルカムメッセージは次のとおりです。

Loading, please wait...
   Volume group "vg-root" not found
   Skipping volume group vg-root
Unable to find LVM volume vg-root/lv-root
   Volume group "vg-other" not found
   Skipping volume group vg-other
Unable to find LVM volume vg-other/lv-swap

Waiting for USB stick to be recognized...
[   3.159979] sd 7:0:0:0: [sdd] No Caching mode page found
[   3.160152] sd 7:0:0:0: [sdd] Assuming drive cache: write through

Can't find /boot/myKeyfile.key; USB stick not present. 

Manually unlock the disk (sda1_crypt)
Enter passphrase:

パスワードを入力すると、2番目のディスクでも同じスワップが発生しますsdb1_crypt


私は何か間違っているのですが、何か分かりません。CRYPTDISKS_MOUNT「暗号化されたディスクを呼び出す前にマウントするマウントポイントを指定してください」なので、ロック解除プロセスが始まる前に追加できると/boot思いました。/bootところで実行時にはインストールにならないようです/bin/passphrase-from-usb

myKeyfile.key両方のドライブにLUKSキーとして追加され、initramfsviaを更新したと確信していますupdate-initramfs -u

ベストアンサー1

起動中、initramfsは/bootをマウントしません。 /bootにあるファイルを使用するには、/bootを手動でマウントできます。 passphrase-from-usbスクリプトに次のコマンドを追加できます。

mkdir -p /tmp-boot
mount <usb uuid> /tmp-boot -t ext4
dd if=/tmp-boot/myKeyfile.key bs=1 count=256 2>/dev/null
umount /tmp-boot

このhttp://wejn.org/how-to-make-passwordless-cryptsetup.htmlとても役に立ちます。

おすすめ記事