grimm-nixos-laptop/hardening/ssh-as-sudo.nix

50 lines
1.2 KiB
Nix
Raw Normal View History

2025-01-03 15:57:36 +01:00
{ pkgs, lib, ... }:
{
services.openssh = {
enable = true;
2025-01-31 19:42:46 +01:00
settings = {
PasswordAuthentication = false;
challengeResponseAuthentication = false;
# PermitRootLogin = "no";
KbdInteractiveAuthentication = false;
};
2025-01-03 15:57:36 +01:00
# settings.UsePAM = false;
openFirewall = lib.mkDefault false;
allowSFTP = lib.mkDefault false;
# startWhenNeeded = true;
2025-01-12 23:00:12 +01:00
extraConfig = ''
2025-01-31 19:42:46 +01:00
allowtcpforwarding no
2025-01-12 23:00:12 +01:00
X11Forwarding no
AllowAgentForwarding no
AllowStreamLocalForwarding no
AuthenticationMethods publickey
2025-01-31 19:42:46 +01:00
Protocol 2
MaxAuthTries 4
PermitEmptyPasswords no
PermitUserEnvironment no
MaxSessions 4
LoginGraceTime 60
ClientAliveCountMax 3
ClientAliveInterval 15
HostbasedAuthentication no
IgnoreRhosts yes
banner /etc/issue.net
maxstartups 10:30:60
2025-01-12 23:00:12 +01:00
'';
2025-01-03 15:57:36 +01:00
};
users.users.root = {
# isSystemUser = true;
# isNormalUser = true;
uid = 0;
openssh.authorizedKeys.keyFiles = [ ../ssh/id_ed25519_sk.pub ];
# home = "/root";
hashedPassword = null;
createHome = lib.mkForce true;
};
programs.ssh.startAgent = true;
# security.sudo.enable = false;
# services.yubikey-agent.enable = true;
}