是否可以确定哪个 luks 插槽已用于解锁加密分区?

rat*_*noz 4 luks

我处于一种(糟糕的)情况,我有多个正确的密码并使用了 luks 插槽,但我无法分辨哪个密码属于哪个插槽

解密(在启动期间感谢 crypttab)效果很好,但我无法判断哪个插槽已被使用。为了合理化这种情况,有没有办法确定哪个luks槽被使用了呢?

这个问题我读到:

如果您忘记了其中一个密码,那么您只能通过消除来找到它所在的位置,而如果您忘记了其中两个密码,则无法区分哪个是哪个(否则密码哈希将被破坏)。

...所以我有点害怕测试每个密码的每个插槽,即使我没有在手册页中找到任何损坏的密码哈希的参考。

注意:幸运的是,第一个 luks 插槽是已知的,所以我可以通过重置其他插槽来重新站起来。

fro*_*utz 6

打开的 LUKS 容器不知道它是用哪个键槽打开的。所以不,您稍后无法确定哪个插槽“已被使用”。

但是,如果您知道有效的密钥或密码,则可以确定它位于哪个插槽,例如通过使用cryptsetup open,--test-passphrase--key-slot选项重新运行--verbose

正常操作(信息不多):

# cryptsetup open --test-passphrase luks.img 
Enter passphrase for foobar.img: first
# cryptsetup open --test-passphrase luks.img 
Enter passphrase for foobar.img: second
# cryptsetup open --test-passphrase luks.img 
Enter passphrase for foobar.img: third
Run Code Online (Sandbox Code Playgroud)

详细操作(告诉您使用了哪个键槽):

# cryptsetup --verbose open --test-passphrase luks.img 
Enter passphrase for foobar.img: first
Key slot 0 unlocked.
Command successful.
# cryptsetup --verbose open --test-passphrase luks.img 
Enter passphrase for foobar.img: second
Key slot 1 unlocked.
Command successful.
# cryptsetup --verbose open --test-passphrase luks.img 
Enter passphrase for foobar.img: third
Key slot 2 unlocked.
Command successful.
Run Code Online (Sandbox Code Playgroud)

具体的keyslot操作(只接受存储在该slot中的key):

# cryptsetup open --tries 1 --test-passphrase --key-slot 2 luks.img
Enter passphrase for luks.img: first
No key available with this passphrase.
# cryptsetup open --tries 1 --test-passphrase --key-slot 2 luks.img
Enter passphrase for luks.img: second
No key available with this passphrase.
# cryptsetup open --tries 1 --test-passphrase --key-slot 2 luks.img
Enter passphrase for luks.img: third
Run Code Online (Sandbox Code Playgroud)

通常,详细模式提供了足够的信息,但是在查找重复的密码短语(存储在两个单独的插槽中的相同密钥)时,直接指定密钥插槽可能会很有用。与测试所有插槽相比,仅测试一个插槽也更快(不过,优化 LUKS 打开速度是另一个主题)。