个人工具
登录
查看“UbuntuHelp:FeistyLUKSTwoFormFactor”的源代码 - Ubuntu中文
UbuntuHelp
讨论
查看源代码
历史
搜索
导航
首页
最近更改
随机页面
页面分类
帮助
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息
查看“UbuntuHelp:FeistyLUKSTwoFormFactor”的源代码
来自Ubuntu中文
←
UbuntuHelp:FeistyLUKSTwoFormFactor
跳转至:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
== Install usbcryptkey Script == `usbcryptkey` will ease the mounting/unmounting of the LUKS encrypted USB flash drive. It will be called during the `initramfs/local-top/cryptroot` call at startup. <pre><nowiki> vi /bin/usbcryptkey </nowiki></pre> <pre><nowiki> #!/bin/sh # CryptKey value sent from cryptroot # Contains the devicename # LUKS Options # Could pull from cryptroot but this allows for the 'USB Key' to be setup # differently than the crypt volumes it is unlocking. LUKS_OPTS="--readonly --cipher=aes-cbc-essiv:sha256 --hash=sha512 --key-size=256" # Get the device name DEVNAME=$1 # Likely not needed if called from cryptroot correctly # but it doesn't hurt. modprobe -q dm_crypt mount_usbcryptkey () { # Wait for the USB Device # PREREQ udev for cryptroot # If the USB Device hasn't been created wait a bit. count=0 while [ $count -lt 3 ]; do count=$(( $count + 1 )) if [ ! -e $DEVNAME ]; then sleep 5 else break fi done # Check device is LUKS format cryptsetup isLuks $DEVNAME if [ $? -ne 0 ]; then echo "CryptKey device $DEVNAME is not LUKS formated!" exit 1 fi # Open the USB key count=0 openstat=0 while [ $count -lt 3 ]; do count=$(( $count + 1 )) if [ ! -e /dev/mapper/theKeys ]; then echo -n "USB CryptKey ==> " cryptsetup luksOpen $DEVNAME theKeys < /dev/console openstat=$? else break fi done # If it didn't open don't try anything else. if [ $openstat -ne 0 ]; then exit $openstat fi # Mount the opened USB if [ ! -d /mnt/cryptkeys ]; then mkdir -p -m 0700 /mnt/cryptkeys > /dev/null 2>&1 fi count=0 while [ $count -lt 3 ]; do count=$(( $count + 1 )) if [ ! -e /dev/mapper/theKeys ]; then sleep 5 else mount -n -r -t ext2 /dev/mapper/theKeys /mnt/cryptkeys > /dev/null 2>&1 break fi done } umount_usbcryptkey () { # Unmount and close the USB Keys umount /mnt/cryptkeys > /dev/null 2>&1 cryptsetup luksClose theKeys > /dev/null 2>&1 } # Begin work... # If the device is mounted UNMOUNT it. # If the device is not mounted MOUNT it. if [ -z $1 ]; then echo "No device specified!" echo "usbcryptkey DEVNAME" exit 1; fi if [ -r /dev/mapper/theKeys ]; then umount_usbcryptkey exit 0; else mount_usbcryptkey exit 0; fi </nowiki></pre> Now make the file executable. <pre><nowiki> chmod 750 /bin/usbcryptkey </nowiki></pre>
返回至
UbuntuHelp:FeistyLUKSTwoFormFactor
。