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

Expand support for and document systemd-cryptenroll #139433

Closed
j0hax opened this issue Sep 25, 2021 · 9 comments
Closed

Expand support for and document systemd-cryptenroll #139433

j0hax opened this issue Sep 25, 2021 · 9 comments
Labels
0.kind: enhancement Add something new 0.kind: question Requests for a specific question to be answered 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: systemd 9.needs: reporter feedback This issue needs the person who filed it to respond

Comments

@j0hax
Copy link
Member

j0hax commented Sep 25, 2021

Describe the issue

The upgrade from systemd 247 to 249 recently landed in nixpkgs-unstable. Version 248 brought support for systemd-cryptenroll, which allows for automatica unlocking of LUKS2 volumes with diverse security hardware.

In my specific case, I would like to use a FIDO2 security key as described in Lennart Poettering's blog post, which requires an entry in /etc/crypttab.

Running systemd-cryptenroll correctly configures LUKS slots and tokens, and setting

environment.etc.crypttab = {
    enable = true;
    text = ''
      cryptroot /dev/sda2 - fido2-device=auto
    '';
  };

in my system configuration provides the correct file and appears to integrate with systemd when rebuilding. However I am still asked to provide a password for /dev/sda2 when rebooting with zero interaction from my security key.

Expected behavior

Unlocking LUKS at boot by confirming user presence. Ideally this could be managed by a NixOS Module such as luksroot.

Additional Context

Notify maintainers

@andir @eelco @flokli @kloenk

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"x86_64-linux"`
 - host os: `Linux 5.10.68, NixOS, 21.11 (Porcupine)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.4pre20210908_3c56f62`
 - channels(root): `"nixos-21.11pre313466.bc06c93905f"`
 - channels(johannes): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute: cryptsetup
# a list of nixos modules affected by the problem
module: systemd
@j0hax j0hax added 0.kind: bug Something is broken 0.kind: enhancement Add something new 0.kind: question Requests for a specific question to be answered 6.topic: systemd and removed 0.kind: bug Something is broken labels Sep 25, 2021
@veprbl veprbl added the 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS label Sep 25, 2021
@flokli
Copy link
Contributor

flokli commented Oct 7, 2021

@j0hax you might want to take a look at #139864, which should provide some guidelines, and verify this actually works with non-root partitions and /etc/crypttab.

@flokli
Copy link
Contributor

flokli commented Oct 7, 2021

#139864 has been merged, the staging branch of nixpkgs should contain this.

Can you take a look at this and report back?

@flokli flokli added the 9.needs: reporter feedback This issue needs the person who filed it to respond label Oct 7, 2021
@NickCao
Copy link
Member

NickCao commented Dec 4, 2021

Tested with tpm2 and fido2, all working as intended.

@NickCao NickCao closed this as completed Dec 4, 2021
@ivankovnatsky
Copy link
Contributor

(sorry for commenting on a closed issue)

I'm still being asked for the password, though the configuration went fine, Can you please share your configuration? maybe I'm just missing something?

running nixos-unstable

I have this in my config:

  environment.etc.crypttab = {
    enable = true;
    text = ''
      crypted /dev/nvme0n1p2 - tpm2-device=auto
    '';
  };

@NickCao
Copy link
Member

NickCao commented Dec 5, 2021

I'm using nearly identical configuration, you may test the correctness of your setup with:
sudo /run/current-system/systemd/lib/systemd/systemd-cryptsetup attach crypted /dev/nvme0n1p2 - tpm2-device=auto

@ivankovnatsky
Copy link
Contributor

yes, as expected:

sudo /run/current-system/systemd/lib/systemd/systemd-cryptsetup attach crypted /dev/nvme0n1p2 - tpm2-device=auto
Volume crypted already active.

did you tweak something under this config: https://github.com/ivankovnatsky/nixos-config/blob/main/hosts/thinkpad/boot.nix#L13 ?

@NickCao
Copy link
Member

NickCao commented Dec 5, 2021

systemd-cryptsetup won't work in initrd yet

@ivankovnatsky
Copy link
Contributor

ah, got it.

@flokli
Copy link
Contributor

flokli commented Dec 8, 2021

systemd in initrd is discussed at #120015 (and other issues/PRs linked to/from there)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: enhancement Add something new 0.kind: question Requests for a specific question to be answered 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: systemd 9.needs: reporter feedback This issue needs the person who filed it to respond
Projects
None yet
Development

No branches or pull requests

5 participants