17.8. 使用命令行更改 LUKS 密码短语
使用命令行更改加密磁盘或分区上的 LUKS 密码短语。使用 cryptsetup
实用程序,您可以使用各种配置选项和功能控制加密过程,并在现有自动化工作流中集成。
先决条件
-
您有
root
权限或使用sudo
输入管理命令的权限。
流程
更改 LUKS 加密设备中现有的密码短语:
cryptsetup luksChangeKey /dev/<device_ID>
# cryptsetup luksChangeKey /dev/<device_ID>
Copy to Clipboard Copied! 将
<device_ID
> 替换为设备设计器,例如sda
。如果您配置了多个密钥插槽,您可以指定要使用的插槽:
cryptsetup luksChangeKey /dev/<device_ID> --key-slot <slot_number>
# cryptsetup luksChangeKey /dev/<device_ID> --key-slot <slot_number>
Copy to Clipboard Copied! 将
<slot_number
> 替换为您要修改的密钥插槽的数量。插入当前的密码短语和新密码短语:
Enter passphrase to be changed: Enter new passphrase: Verify passphrase:
Enter passphrase to be changed: Enter new passphrase: Verify passphrase:
Copy to Clipboard Copied! 验证新密码短语:
cryptsetup --verbose open --test-passphrase /dev/<device_ID>
# cryptsetup --verbose open --test-passphrase /dev/<device_ID>
Copy to Clipboard Copied!
验证
验证新密码短语是否可以解锁设备:
Enter passphrase for /dev/<device_ID>: Key slot <slot_number> unlocked. Command successful.
Enter passphrase for /dev/<device_ID>: Key slot <slot_number> unlocked. Command successful.
Copy to Clipboard Copied!