2026-01-01 01:36:58 -05:00
|
|
|
{ pkgs, inputs, config, keys, ... }: {
|
2026-04-04 04:57:47 -04:00
|
|
|
users.users.ai-worker = {
|
2026-01-01 01:36:58 -05:00
|
|
|
isSystemUser = true;
|
2026-04-04 04:57:47 -04:00
|
|
|
group = "ai-worker";
|
2026-04-04 17:07:13 -04:00
|
|
|
home = "/home/ai-worker";
|
|
|
|
|
createHome = true;
|
2026-01-01 01:36:58 -05:00
|
|
|
extraGroups = [ "docker" ];
|
|
|
|
|
shell = pkgs.bashInteractive;
|
|
|
|
|
openssh.authorizedKeys.keys = [
|
2026-04-04 04:57:47 -04:00
|
|
|
keys.users.ai-worker.main
|
2026-01-01 01:36:58 -05:00
|
|
|
];
|
|
|
|
|
};
|
2026-04-04 04:57:47 -04:00
|
|
|
users.groups.ai-worker = {};
|
2026-04-30 17:33:05 +00:00
|
|
|
|
2026-04-30 17:36:13 +00:00
|
|
|
# Restricted sudo for ai-worker - security checks only
|
2026-04-30 17:33:05 +00:00
|
|
|
security.sudo.extraRules = [
|
|
|
|
|
{
|
|
|
|
|
users = [ "ai-worker" ];
|
|
|
|
|
commands = [
|
2026-04-30 17:36:13 +00:00
|
|
|
# Firewall checks
|
2026-04-30 17:33:05 +00:00
|
|
|
{
|
|
|
|
|
command = "/run/wrappers/bin/sudo iptables -L -n -v";
|
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
command = "/run/wrappers/bin/sudo iptables -S";
|
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
|
}
|
2026-04-30 17:36:13 +00:00
|
|
|
# Fail2ban status
|
2026-04-30 17:33:05 +00:00
|
|
|
{
|
|
|
|
|
command = "/run/current-system/sw/bin/fail2ban-client status";
|
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
command = "/run/current-system/sw/bin/fail2ban-client status *";
|
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
command = "/run/current-system/sw/bin/fail2ban-client get * banned";
|
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
|
}
|
2026-04-30 17:36:13 +00:00
|
|
|
# Log inspection
|
2026-04-30 17:33:05 +00:00
|
|
|
{
|
|
|
|
|
command = "/run/current-system/sw/bin/journalctl -t kernel -n 100";
|
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
command = "/run/current-system/sw/bin/journalctl -u fail2ban -n 50";
|
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
|
}
|
2026-04-30 17:36:13 +00:00
|
|
|
{
|
|
|
|
|
command = "/run/current-system/sw/bin/journalctl -u firewall -n 50";
|
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
|
}
|
|
|
|
|
# SSH config verification
|
2026-04-30 17:33:05 +00:00
|
|
|
{
|
|
|
|
|
command = "/run/current-system/sw/bin/sshd -T";
|
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
|
}
|
2026-04-30 17:36:13 +00:00
|
|
|
# Docker service checks
|
2026-04-30 17:33:05 +00:00
|
|
|
{
|
|
|
|
|
command = "/run/current-system/sw/bin/docker ps";
|
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
command = "/run/current-system/sw/bin/docker inspect *";
|
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
|
}
|
|
|
|
|
# Network diagnostics
|
|
|
|
|
{
|
|
|
|
|
command = "/run/current-system/sw/bin/ss -tlnp";
|
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
command = "/run/current-system/sw/bin/cat /proc/net/tcp";
|
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
];
|
2026-01-01 02:25:34 -05:00
|
|
|
}
|