Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to enroll luks device for unlock methods (e.g. TPM2) #709

Open
MattSturgeon opened this issue Jul 19, 2024 · 5 comments
Open

Option to enroll luks device for unlock methods (e.g. TPM2) #709

MattSturgeon opened this issue Jul 19, 2024 · 5 comments
Labels
documentation Issue that would be fixed by proper documentation enhancement New feature or request

Comments

@MattSturgeon
Copy link
Member

It would be useful to have an option for luks devices to enable TPM2 unlock (and maybe others like FIDO2 or PKCS11 too?).

This would be more convenient than running sudo systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+7 /dev/<device> after using disko.

An error should be thrown if the option is used on a system without TPM2 support.

@iFreilicht iFreilicht added enhancement New feature or request contributions welcome There's nothing left to discuss, feel free to submit a PR for this! and removed contributions welcome There's nothing left to discuss, feel free to submit a PR for this! labels Sep 20, 2024
@iFreilicht
Copy link
Contributor

iFreilicht commented Sep 20, 2024

Wouldn't it be possible to just use something like this?

postCreateHook="systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+7 /dev/<device>";

Or is there some distinct advantage to implementing this feature in disko directly?

@Mic92
Copy link
Member

Mic92 commented Sep 21, 2024

It's most a documentation issue I suppose. Having a NixOS option can help with that, but also a template could.

@iFreilicht iFreilicht added the documentation Issue that would be fixed by proper documentation label Sep 21, 2024
@kagehisa
Copy link

kagehisa commented Dec 1, 2024

Wouldn't it be possible to just use something like this?

postCreateHook="systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+7 /dev/<device>";

Or is there some distinct advantage to implementing this feature in disko directly?

So far I just used disko for simple partition layouts, but this time I would like to use it to create a luks setup with a fido2 device to unlock it. I have the basics down I guess (using systemd enabled initrd as described in the nixos manual).

The only thing that is missing is to have the systemd-cryptenroll done. The solution with postCreateHook sounds good to me, but I couldn't find an example where a hook is used for a luks device. And according to this comment there is no support for running hooks on a luks device if I understood that correctly.

Do I need to run the hook after the filesystem creation that is using the luks device? Is there maybe an example that shows on what level the hook has to be set?

@phaer
Copy link
Member

phaer commented Dec 13, 2024

And according to #415 (comment) comment there is no support for running hooks on a luks device if I understood that correctly.

I believe the reason for this is just that noone with enough interest in such a feature implemented it yet. I personally don't have a use-case but I am happy to review PRs for that and provide guidance where I can. I wrote the original implementation for zfs and think the one for luks could work almost the same.

@kagehisa
Copy link

kagehisa commented Dec 13, 2024

@phaer would you be so kind to point me to the src for this? I looked in lib/types/ at all zfs related files but I wasn't able to pinpoint the hook related code. The disko source is a bit puzzling for me tbo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Issue that would be fixed by proper documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants