@@ -36,6 +36,16 @@ let
3636 '';
3737 };
3838
39+ u2fAuth = mkOption {
40+ default = config.security.pam.enableU2F;
41+ type = types.bool;
42+ description = ''
43+ If set, users listed in
44+ <filename>~/.yubico/u2f_keys</filename> are able to log in
45+ with the associated U2F key.
46+ '';
47+ };
48+
3949 usbAuth = mkOption {
4050 default = config.security.pam.usb.enable;
4151 type = types.bool;
@@ -209,6 +219,8 @@ let
209219 "auth sufficient ${pkgs.pam_ssh_agent_auth}/libexec/pam_ssh_agent_auth.so file=~/.ssh/authorized_keys:~/.ssh/authorized_keys2:/etc/ssh/authorized_keys.d/%u"}
210220 ${optionalString cfg.fprintAuth
211221 "auth sufficient ${pkgs.fprintd}/lib/security/pam_fprintd.so"}
222+ ${optionalString cfg.u2fAuth
223+ "auth sufficient ${pkgs.pam_u2f}/lib/security/pam_u2f.so"}
212224 ${optionalString cfg.usbAuth
213225 "auth sufficient ${pkgs.pam_usb}/lib/security/pam_usb.so"}
214226 ${optionalString cfg.unixAuth
@@ -364,6 +376,13 @@ in
364376 '';
365377 };
366378
379+ security.pam.enableU2F = mkOption {
380+ default = false;
381+ description = ''
382+ Enable the U2F PAM module.
383+ '';
384+ };
385+
367386 security.pam.enableEcryptfs = mkOption {
368387 default = false;
369388 description = ''
@@ -392,6 +411,7 @@ in
392411 ++ optionals config.krb5.enable [pam_krb5 pam_ccreds]
393412 ++ optionals config.security.pam.enableOTPW [ pkgs.otpw ]
394413 ++ optionals config.security.pam.enableOATH [ pkgs.oathToolkit ]
414+ ++ optionals config.security.pam.enableU2F [ pkgs.pam_u2f ]
395415 ++ optionals config.security.pam.enableEcryptfs [ pkgs.ecryptfs ];
396416
397417 security.setuidPrograms =