mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 22:11:33 +01:00
Create networking abstraction on top of nebula
This commit is contained in:
parent
6804112df6
commit
252abe9443
15 changed files with 223 additions and 165 deletions
57
modules/system/services/sshd.nix
Normal file
57
modules/system/services/sshd.nix
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
config,
|
||||
self,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.custom.services.sshd;
|
||||
netCfg = config.custom.networking;
|
||||
in
|
||||
{
|
||||
options.custom.services.sshd.enable = lib.mkEnableOption "";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
meta.ports.tcp = [ 22 ];
|
||||
|
||||
services = {
|
||||
openssh = {
|
||||
enable = true;
|
||||
openFirewall = false;
|
||||
ports = [ ];
|
||||
listenAddresses = lib.singleton {
|
||||
addr = netCfg.overlay.address;
|
||||
port = 22;
|
||||
};
|
||||
settings = {
|
||||
PasswordAuthentication = false;
|
||||
KbdInteractiveAuthentication = false;
|
||||
PermitRootLogin = "no";
|
||||
};
|
||||
};
|
||||
|
||||
nebula.networks.mesh.firewall.inbound =
|
||||
netCfg.peers
|
||||
|> lib.filter (node: node.isClient)
|
||||
|> lib.map (client: {
|
||||
port = 22;
|
||||
proto = "tcp";
|
||||
host = client.hostname;
|
||||
});
|
||||
};
|
||||
|
||||
systemd.services.sshd = {
|
||||
requires = [ netCfg.overlay.systemdUnit ];
|
||||
after = [ netCfg.overlay.systemdUnit ];
|
||||
};
|
||||
|
||||
users.users.seb.openssh.authorizedKeys.keyFiles =
|
||||
self.nixosConfigurations
|
||||
|> lib.attrValues
|
||||
|> lib.filter (host: host.config.custom.networking.hostname != netCfg.hostname)
|
||||
|> lib.filter (host: host.config |> lib.hasAttr "home-manager")
|
||||
|> lib.map (host: host.config.home-manager.users.seb.custom.programs.ssh)
|
||||
|> lib.filter (ssh: ssh.enable)
|
||||
|> lib.map (ssh: ssh.publicKeyPath);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue