page counter next up previous contents
Next: 檔案系統設定 Label Up: LUKS 加密根目錄 Previous: keyfile 存放檔案系統準備   Contents   DYWANG_HOME

新增 LUKS 的 keyfiles

  1. 在 xfs, ext4 及 vfat 三個 lv 掛載目錄下,各新增一把金鑰。
    [root@kvm7 ~]# dd if=/dev/urandom of=/mnt/lukskey/xfs/xfskeyfile bs=1024 count=4
    4+0 records in
    4+0 records out
    4096 bytes (4.1 kB) copied, 0.000942181 s, 4.3 MB/s
    [root@kvm7 ~]# dd if=/dev/urandom of=/mnt/lukskey/ext4/ext4keyfile bs=1024 count=4
    4+0 records in
    4+0 records out
    4096 bytes (4.1 kB) copied, 0.000761101 s, 5.4 MB/s
    [root@kvm7 ~]# dd if=/dev/urandom of=/mnt/lukskey/vfat/vfatkeyfile bs=1024 count=4
    4+0 records in
    4+0 records out
    4096 bytes (4.1 kB) copied, 0.00172373 s, 2.4 MB/s
    
  2. 將 xfs, ext4 及 vfat 三個 lv 掛載目錄下的金鑰,都新增為開啟 /dev/vdb1 的金鑰。
    [root@kvm7 ~]# cryptsetup luksAddKey /dev/vdb1 /mnt/lukskey/xfs/xfskeyfile 
    Enter any existing passphrase: 
    [root@kvm7 ~]# cryptsetup luksAddKey /dev/vdb1 /mnt/lukskey/ext4/ext4keyfile 
    Enter any existing passphrase: 
    [root@kvm7 ~]# cryptsetup luksAddKey /dev/vdb1 /mnt/lukskey/vfat/vfatkeyfile 
    Enter any existing passphrase:
    
  3. 查看 /dev/vdb1 的金鑰,目前有 Key Slot 0 至 4 共 5 把金鑰。
    [root@kvm7 ~]# cryptsetup luksDump /dev/vdb1
    LUKS header information for /dev/vdb1
    
    Version:		1
    Cipher name:	aes
    Cipher mode:	xts-plain64
    Hash spec:		sha256
    Payload offset:	4096
    MK bits:		256
    MK digest:		dc f8 00 ba 18 9d ee 80 80 27 c9 5e 2b e4 88 5e e0 05 d6 39 
    MK salt:		d1 3e 91 cb 80 f3 4f 9d 91 c4 da e2 25 e2 5b 5e 
    				78 d5 07 de 04 6e fd 9e 48 4d 8a 31 49 42 16 f5 
    MK iterations:	35008
    UUID:			77472cc9-0dd3-4c4c-81ad-e0ecae7570b2
    
    Key Slot 0: ENABLED
    	Iterations:				556568
    	Salt:					6f ea 6a 2c c8 4b 97 d2 47 c9 6b c8 ef b2 d7 86 
    							a6 58 41 14 8f 34 3f a9 d4 25 02 6c 0e c8 a6 12 
    	Key material offset:	8
    	AF stripes:				4000
    Key Slot 1: ENABLED
    	Iterations:				563144
    	Salt:					66 0e 2e c1 8a a3 3f cb 21 7d 50 ed aa 96 3d d7 
    							09 54 36 a9 15 5a b1 3e 4e fe 35 d6 10 b3 ac 35 
    	Key material offset:	264
    	AF stripes:				4000
    Key Slot 2: ENABLED
    	Iterations:				517558
    	Salt:					59 ef 20 e6 1b da 6e b9 03 0f c4 8c 4d 1a 57 71 
    							5d 18 92 e8 da 42 b9 9b 00 0f f2 17 ee e1 10 41 
    	Key material offset:	520
    	AF stripes:				4000
    Key Slot 3: ENABLED
    	Iterations:				539946
    	Salt:					8b 0e d0 09 ad 19 77 51 a6 5c 61 24 37 24 a6 02 
    							f2 95 02 6e 36 52 52 fb 2a 24 66 56 ad 54 2f fd 
    	Key material offset:	776
    	AF stripes:				4000
    Key Slot 4: ENABLED
    	Iterations:				520642
    	Salt:					7f 34 1c 22 4d 97 1d 9f d2 fe fb 8b 4c 47 42 de 
    							b0 a5 6d 82 54 0e 26 65 f5 4f ac 9e 9e 8a 01 33 
    	Key material offset:	1032
    	AF stripes:				4000
    Key Slot 5: DISABLED
    Key Slot 6: DISABLED
    Key Slot 7: DISABLED
    



De-Yu Wang 2020-05-14