NixOS LUKS encryption using a YubiKey

I repeated all the steps manually and it stills shows “Authentication failed!”

Seems like something may be misconfigured with the YubiKey or LUKS then.

What version of the YubiKey do you have? Looks like there are a variety of them to choose from, and since I’m not familiar with them, perhaps this encrypted disk tutorial is using a feature not available on your model?

From reading about the YubiKey 5, it appears you can create an OTP on slot 2. I wonder if maybe you configured slot 2 with OTP at some point, and it’s currently locked (I don’t know if that’s a thing). The tutorials seem clear, so I’m grasping at straws to figure out why it won’t work for you.

If you run five trials against your YubiKey with a single challenge, for example
ykchalresp -2 -x "hello world" 2>/dev/null, do you get the same response every time, or does it change with each run? If it changes, then maybe that slot thinks it’s supposed to do OTP instead of chal-resp + chal-hmac.