Nit*_*hin 14 encryption luks disk-encryption
研究硬盘加密。转到解决方案似乎是使用密码使用 LUKS 的 dm-crypt。我使用安装到磁盘池中的多个独立硬盘进行读取。在这种情况下,我必须多次输入密码。
有没有办法让我用密钥文件加密硬盘,也许把它放在一个 USB 驱动器上,必要时插入它?
Cel*_*ada 11
最好的方法之一是使用带有加密密钥的智能卡来解锁加密块设备的密钥。您只需要输入密码短语(工具称为“PIN”,但它实际上是密码短语)一次,之后它将被缓存。这具有使用您拥有的东西(智能卡本身,无法从中提取私钥)和您知道的东西(密码短语)保护加密数据的额外优势。
/etc/crypttab像这样格式化:
mapper-name /dev/disk/raw-device /var/lib/filename-containing-encrypted-key \
luks,keyscript=/lib/cryptsetup/scripts/decrypt_opensc
Run Code Online (Sandbox Code Playgroud)
在 Debian 及其衍生版本中,initramfs-tools 会注意到 keyscript 并自动将访问智能卡的所有必要工具和守护进程复制到 initramfs。
有关设置智能卡和创建(和加密)密钥的信息可在 中找到/usr/share/doc/cryptsetup/README.opensc.gz。
为此,您可以使用Yubikey 4或Yubikey NEO等。
实施说明:此功能具有粗糙的边缘,显然无法立即使用,因此 YMMV。上次我成功实现它时,我不得不添加以下技巧:
systemd因为它灾难性地尝试接管设置加密设备的整个过程,/etc/crypttab但它不知道keyscript导致大失败的原因。幸运的是,在 Debian 中,您仍然可以选择退出systemd.安装这个 fixer-upper 脚本是/etc/initramfs-tools/hooks/yubipin因为内置功能没有安装足够的支持来让 Yubikey 从 initramfs 中可用。您可能需要对此进行调整。
#!/bin/sh
PREREQ=cryptroot
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
# /scripts/local-top/cryptopensc calls pcscd with the wrong path
ln -s ../usr/sbin/pcscd ${DESTDIR}/sbin/pcscd
mkdir -p "${DESTDIR}/usr/lib/x86_64-linux-gnu"
# opensc-tool wants this dynamically, copy_exec doesn't know that
cp -pL /usr/lib/x86_64-linux-gnu/libpcsclite.so.1 "${DESTDIR}/usr/lib/x86_64-linux-gnu/libpcsclite.so.1"
mkdir -p "${DESTDIR}/lib/x86_64-linux-gnu"
# without this, pcscd aborts with a pthread_cancel error
cp -pL /lib/x86_64-linux-gnu/libgcc_s.so.1 "${DESTDIR}/lib/x86_64-linux-gnu/libgcc_s.so.1"
# this gets copied as a dangling symlink, fix it
rm "${DESTDIR}/usr/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Info.plist"
cp -pL /usr/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Info.plist "${DESTDIR}/usr/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Info.plist"
# pcscd needs this to open the reader once it has found it
cp -pL /lib/x86_64-linux-gnu/libusb-1.0.so.0 "${DESTDIR}/lib/x86_64-linux-gnu/libusb-1.0.so.0"
Run Code Online (Sandbox Code Playgroud)安装另一个脚本/etc/initramfs-tools/scripts/local-bottom/killpcscd来清理:
#!/bin/sh
set -e
PREREQ=cryptopensc
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
# because cryptopensc does not do it properly
killall pcscd
Run Code Online (Sandbox Code Playgroud)