在CentOS 6.4中更改磁盘encryption密钥

在CentOS 6安装过程中,我检查了Anaconda安装程序中的“encryption”checkbox,它在PV(物理卷)分区级别进行encryption。

现在,出于一些安全原因,我想更改当前的encryption密钥。 有没有办法做到这一点?

默认的encryption方法使用LUKS ,所以问题是:

# cryptsetup luksDump /dev/sda LUKS header information for /dev/sda2 Version: 1 Cipher name: aes Cipher mode: xts-plain64 Hash spec: sha1 Payload offset: 4096 MK bits: 512 MK digest: ec 80 b6 a6 f4 b6 23 29 d6 22 53 2c af c6 a6 06 01 ca 7c 34 MK salt: 97 4c c5 fe 39 e5 ec f7 3c 7a a5 bd 98 34 56 b4 0d c4 cc c2 ab 74 fa 5c bd d3 0f e3 ae 65 c3 d7 MK iterations: 59625 UUID: d8bfb76f-fec3-4d6e-8801-5ab24517c081 Key Slot 0: ENABLED Iterations: 238801 Salt: 42 37 13 4d 6f d5 eb e6 10 dc 78 c8 04 f9 10 74 48 15 4d e0 68 d5 dc 7f 6a 14 66 a2 88 83 4f 17 Key material offset: 8 AF stripes: 4000 Key Slot 1: DISABLED Key Slot 2: DISABLED Key Slot 3: DISABLED Key Slot 4: DISABLED Key Slot 5: DISABLED Key Slot 6: DISABLED Key Slot 7: DISABLED 

看看你目前使用多less个插槽。 用相应的块设备replace/dev/sda

使用cryptsetup luksAddKey将新密钥添加到空闲插槽,请检查cryptsetup(8)联机帮助页中的可能选项。

之后,重新启动并确保您可以使用新密钥访问机器。 然后你可以删除旧的( cryptsetup luksRemoveKey )。