Better Server cfg
This commit is contained in:
@@ -24,15 +24,20 @@
|
||||
ip4 = "10.10.1.1/32";
|
||||
ip6 = "fd10:10:10::1/128";
|
||||
pubkey = "NFBJvYXZC+bd62jhrKnM7/pugidWhgR6+C5qIiUiq3Q=";
|
||||
server = {
|
||||
enable = true;
|
||||
forward = [
|
||||
};
|
||||
};
|
||||
server = {
|
||||
openssh = true;
|
||||
wireguard = true;
|
||||
nftables = {
|
||||
enable = true;
|
||||
ifs = ["ens3" "wg0" ];
|
||||
ports = [
|
||||
[ "ens3" "10.10.1.2" "fd10:10:10::2" 22 2222 ] # SSH/GIT
|
||||
[ "ens3" "10.10.1.2" "fd10:10:10::2" 80 80 ] # HTTP
|
||||
[ "ens3" "10.10.1.2" "fd10:10:10::2" 443 443 ] # HTTPS
|
||||
[ "ens3" "10.10.1.2" "fd10:10:10::2" 3979 3979 ] # OTTD
|
||||
];
|
||||
};
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,27 +1,14 @@
|
||||
{ config, lib, inputs, ... }:
|
||||
let
|
||||
allUsers = lib.concatMap (peer: if peer.syscfg ? users then peer.syscfg.users else []) config.syscfg.peers;
|
||||
groupedUsers = lib.groupBy (u: u.username) allUsers;
|
||||
allowedUsernames = map (u: u.username) config.syscfg.users;
|
||||
activeUsers = lib.filterAttrs (name: _: lib.elem name allowedUsernames) groupedUsers;
|
||||
in {
|
||||
imports = [ ./hardware.nix ];
|
||||
{ config, lib, inputs, ... }: {
|
||||
imports = [ ./hardware.nix ../../modules/server ];
|
||||
|
||||
services.openssh = {
|
||||
system.autoUpgrade = {
|
||||
enable = true;
|
||||
ports = [ 422 ];
|
||||
banner = "";
|
||||
settings = {
|
||||
PasswordAuthentication = false;
|
||||
PermitRootLogin = "prohibit-password";
|
||||
ClientAliveInterval = 60;
|
||||
ClientAliveCountMax = 3;
|
||||
TCPKeepAlive = true;
|
||||
};
|
||||
flake = "git+https://git.helcel.net/sora/nixconfig";
|
||||
flags = [
|
||||
"--no-write-lock-file"
|
||||
];
|
||||
dates = "04:00";
|
||||
randomizedDelaySec = "30min";
|
||||
allowReboot = false;
|
||||
};
|
||||
users.users = lib.mapAttrs (name: userList: {
|
||||
openssh.authorizedKeys.keys = lib.unique (
|
||||
lib.concatMap (u: if u ? pubssh then [ u.pubssh ] else []) userList
|
||||
);
|
||||
}) activeUsers;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user