Fal*_*alc 7 encryption partitioning mount luks
如何以安全的方式自动挂载 LUKS 加密分区?理想情况下,当我登录时(因此我的密码在登录屏幕上输入),或者当我进入桌面时,Ubuntu 会询问我的密码,然后自动挂载分区?
我的 fdisk 的内容如下
加密的分区是/dev/sdb7,我的根和主分区是/dev/sdb5(未加密)。
Disk /dev/loop0: 14 MiB, 14647296 bytes, 28608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop1: 81.7 MiB, 85692416 bytes, 167368 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x0006d9d9
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 524646399 524644352 250.2G 7 HPFS/NTFS/exFAT
/dev/sda2 * 524646400 1953523711 1428877312 681.4G 83 Linux
Disk /dev/sdb: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x1ffae910
Device Boot Start End Sectors Size Id Type
/dev/sdb1 214892542 976773119 761880578 363.3G 5 Extended
/dev/sdb2 * 2048 2150399 2148352 1G 83 Linux
/dev/sdb5 214892544 257558559 42666016 20.4G 83 Linux
/dev/sdb6 300716032 318294015 17577984 8.4G 82 Linux swap / Solaris
/dev/sdb7 318296064 976773119 658477056 314G 83 Linux
Partition table entries are not in disk order.
Run Code Online (Sandbox Code Playgroud)
您可以使用 pam-mount 来执行此操作。它将挂钩登录过程,从而能够使用输入的密码来安装 luks 分区。设置方法如下:
如果您已有 LUKS 加密的分区或映像,请跳过此部分
在您的主目录中创建一个名为.priv的文件,大小为 1GB:
truncate -s 1G ~/.priv
Run Code Online (Sandbox Code Playgroud)
使用 LUKS 格式化图像并设置密码(使用与登录密码相同的密码):
cryptsetup luksFormat ~/.priv
Run Code Online (Sandbox Code Playgroud)
启用图像:
sudo cryptsetup luksOpen ~/.priv priv
Run Code Online (Sandbox Code Playgroud)
在新设备上创建文件系统:
sudo mkfs.ext4 /dev/mapper/priv
Run Code Online (Sandbox Code Playgroud)
再次禁用图像:
sudo cryptsetup luksClose priv
Run Code Online (Sandbox Code Playgroud)
安装包:
sudo apt install libpam-mount
Run Code Online (Sandbox Code Playgroud)
编辑配置文件/etc/security/pam_mount.conf.xml并向其中添加以下行:
<volume path="~/.priv" mountpoint="~/priv" />
Run Code Online (Sandbox Code Playgroud)
在它所说的地方添加这个<!-- Volume definitions -->。请注意路径和挂载点参数之间微妙但重要的区别。在您的特定情况下,您将使用path="/dev/sdb7".
现在登录到您的计算机,您应该注意到它需要比平常更长的时间。成功登录后,您可以使用mount命令检查您的家中现在是否安装了新的文件系统。它应该类似于:
/dev/mapper/_dev_loop3 on /home/seb/priv type ext4 (rw,relatime,data=ordered,helper=crypt)
Run Code Online (Sandbox Code Playgroud)
/home/seb我正在使用此设置在 Ubuntu 18.04 上从 LUKS 加密映像挂载我的主目录 ( )。pam_mount 还将在我注销后负责卸载映像。因此,如果在安装过程中您没有选择全盘加密,那么这是至少获得一些加密的好方法。