-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5609abe
commit 20ba9d8
Showing
10 changed files
with
115 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,11 +11,22 @@ in { | |
mkOption | ||
{ | ||
default = true; | ||
example = false; | ||
type = types.bool; | ||
description = mdDoc '' | ||
Whether the operating system should be hardened. | ||
''; | ||
}; | ||
duosec = | ||
mkOption | ||
{ | ||
default = false; | ||
example = true; | ||
type = types.bool; | ||
description = mdDoc '' | ||
Whether logins should be protected by Duo Security. | ||
''; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
|
@@ -73,20 +84,48 @@ in { | |
"vivid" | ||
]; | ||
|
||
# Disable coredumps | ||
systemd.coredump.enable = false; | ||
# Protect logins and sudo on servers via DUO | ||
# leaving EnvFactor enabled for other apps | ||
security.duosec = mkIf cfg.duosec { | ||
acceptEnvFactor = true; | ||
autopush = true; | ||
failmode = "safe"; | ||
host = "api-a7b9f5f3.duosecurity.com"; | ||
integrationKey = "DID3CH2NCQ2H24L1GUUN"; | ||
pam.enable = true; | ||
prompts = 1; | ||
pushinfo = true; | ||
secretKeyFile = config.sops.secrets."api_keys/duo".path; | ||
ssh.enable = true; | ||
}; | ||
sops.secrets."api_keys/duo" = mkIf cfg.duosec { | ||
mode = "0600"; | ||
path = "/run/secrets/api_keys/duo"; | ||
}; | ||
security.pam.services = mkIf cfg.duosec { | ||
"login".duoSecurity.enable = true; | ||
"sddm".duoSecurity.enable = mkIf config.dr460nixed.desktops.enable true; | ||
"sudo".duoSecurity.enable = mkIf config.dr460nixed.servers.enable true; | ||
}; | ||
|
||
# Disable root login & password authentication on sshd | ||
# also, apply recommendations of ssh-audit.com and enable Duo 2FA | ||
# (for whatever reason the default config did not work a at all? | ||
# maybe related to https://github.com/NixOS/nixpkgs/issues/115044) | ||
services.openssh = { | ||
extraConfig = '' | ||
AllowTcpForwarding no | ||
ForceCommand /usr/bin/env login_duo | ||
HostKeyAlgorithms ssh-ed25519,[email protected],[email protected],[email protected],rsa-sha2-256,rsa-sha2-512,[email protected],[email protected] | ||
PermitTunnel no | ||
''; | ||
extraConfig = | ||
if cfg.duosec | ||
then '' | ||
AllowTcpForwarding no | ||
ForceCommand /usr/bin/env login_duo | ||
HostKeyAlgorithms ssh-ed25519,[email protected],[email protected],[email protected],rsa-sha2-256,rsa-sha2-512,[email protected],[email protected] | ||
PermitTunnel no | ||
'' | ||
else '' | ||
AllowTcpForwarding no | ||
HostKeyAlgorithms ssh-ed25519,[email protected],[email protected],[email protected],rsa-sha2-256,rsa-sha2-512,[email protected],[email protected] | ||
PermitTunnel no | ||
''; | ||
settings = { | ||
Ciphers = [ | ||
"[email protected]" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters