From ec3bf1cde1ea94d827605f0e9e73ec1843800a97 Mon Sep 17 00:00:00 2001 From: Kleidi Bujari Date: Mon, 16 Feb 2026 13:25:02 -0800 Subject: define simple shared network with mdns for local hosts --- modules/sshd.nix | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 modules/sshd.nix (limited to 'modules/sshd.nix') diff --git a/modules/sshd.nix b/modules/sshd.nix new file mode 100644 index 0000000..86fea58 --- /dev/null +++ b/modules/sshd.nix @@ -0,0 +1,72 @@ +{ + config, + lib, + ... +}: + +let + cfg = config.depot.net.sshd; + inherit (lib) + mkOption + mkDefault + mkIf + types + ; +in +{ + options.depot.net.sshd = { + enable = mkOption { + type = types.bool; + default = false; + description = "Enable hardened SSH service."; + }; + publish = mkOption { + type = types.bool; + default = false; + description = "Publish SSH service over mDNS."; + }; + }; + + config = mkIf cfg.enable { + services.openssh = { + enable = true; + startWhenNeeded = true; + openFirewall = true; + hostKeys = lib.singleton { + path = "/persist/certs/ssh/ssh_host_ed25519_key"; + type = "ed25519"; + }; + settings = { + UsePAM = false; + X11Forwarding = false; + PermitRootLogin = "prohibit-password"; + PasswordAuthentication = mkDefault false; + # Ciphers = [ "chacha20-poly1305@openssh.com" ]; + # Macs = [ "hmac-sha2-512-etm@openssh.com" ]; + # KexAlgorithms = [ "curve25519-sha256@libssh.org" ]; + }; + sftpServerExecutable = "internal-sftp"; + sftpFlags = [ + "-f AUTHPRIV" + "-l INFO" + ]; + # extraConfig = + # let + # pubkeyTypes = lib.strings.concatStringsSep "," [ + # "sk-ssh-ed25519-cert-v01@openssh.com" + # "ssh-ed25519-cert-v01@openssh.com" + # "ssh-ed25519" + # ]; + # in + # "PubkeyAcceptedKeyTypes ${pubkeyTypes}"; + }; + + environment.etc."systemd/dnssd/ssh.dnssd".text = mkIf cfg.publish '' + [Service] + Name=%H + Type=_ssh._tcp + Port=22 + TxtText=hello world + ''; + }; +} -- cgit v1.3.1