diff --git a/docs/options.md b/docs/options.md index ea50bbf..ec5f6d2 100644 --- a/docs/options.md +++ b/docs/options.md @@ -190,6 +190,7 @@ Update module option docs there instead of editing this file by hand. - [knownHostsFile](#services-proxy-suite-sshproxy-knownhostsfile) - [listenAddress](#services-proxy-suite-sshproxy-listenaddress) - [listenPort](#services-proxy-suite-sshproxy-listenport) + - [serviceUser](#services-proxy-suite-sshproxy-serviceuser) - [sshPort](#services-proxy-suite-sshproxy-sshport) - [strictHostKeyChecking](#services-proxy-suite-sshproxy-stricthostkeychecking) - [user](#services-proxy-suite-sshproxy-user) @@ -387,7 +388,8 @@ services.proxy-suite = { identityFile = null; knownHostsFile = null; listenAddress = "127.0.0.1"; - listenPort = 1085; + listenPort = 1091; + serviceUser = null; sshPort = 22; strictHostKeyChecking = "accept-new"; user = null; @@ -670,7 +672,8 @@ services.proxy-suite = { identityFile = "/run/secrets/proxy-suite-ssh-key"; knownHostsFile = "/run/secrets/proxy-suite-ssh-known-hosts"; listenAddress = "127.0.0.1"; - listenPort = 1085; + listenPort = 1091; + serviceUser = "proxy"; sshPort = 22; strictHostKeyChecking = "yes"; user = "root"; @@ -5823,7 +5826,7 @@ Local port for the SSH-created SOCKS5 listener\. *Default:* ```nix -1085 +1091 ``` @@ -5831,7 +5834,41 @@ Local port for the SSH-created SOCKS5 listener\. *Example:* ```nix -1085 +1091 +``` + +*Declared by:* + - [modules/proxy-suite/options/ssh-proxy\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options/ssh-proxy.nix) + + + + +## services\.proxy-suite\.sshProxy\.serviceUser + + + +Unix user for the systemd SSH proxy service\. Leave unset to use +systemd’s default user\. + + + +*Type:* +null or string matching the pattern \[^\[:space:]]+ + + + +*Default:* + +```nix +null +``` + + + +*Example:* + +```nix +"proxy" ``` *Declared by:* diff --git a/modules/proxy-suite/options/ssh-proxy.nix b/modules/proxy-suite/options/ssh-proxy.nix index 4e11bd7..33c12a7 100644 --- a/modules/proxy-suite/options/ssh-proxy.nix +++ b/modules/proxy-suite/options/ssh-proxy.nix @@ -17,6 +17,16 @@ in example = "root"; }; + serviceUser = mkOption { + type = types.nullOr (types.strMatching "[^[:space:]]+"); + default = null; + description = '' + Unix user for the systemd SSH proxy service. Leave unset to use + systemd's default user. + ''; + example = "proxy"; + }; + host = mkOption { type = types.nullOr (types.strMatching "[^[:space:]]+"); default = null; @@ -42,9 +52,9 @@ in listenPort = mkOption { type = types.port; - default = 1085; + default = 1091; description = "Local port for the SSH-created SOCKS5 listener."; - example = 1085; + example = 1091; }; identityFile = mkOption { diff --git a/modules/proxy-suite/ssh-proxy.nix b/modules/proxy-suite/ssh-proxy.nix index 113ce8d..3ff489b 100644 --- a/modules/proxy-suite/ssh-proxy.nix +++ b/modules/proxy-suite/ssh-proxy.nix @@ -38,6 +38,9 @@ in ExecStart = startScript; Restart = "on-failure"; RestartSec = 5; + } + // lib.optionalAttrs (s.serviceUser != null) { + User = s.serviceUser; }; }; } diff --git a/nix/checks/ssh-proxy.nix b/nix/checks/ssh-proxy.nix index e380afa..a08787c 100644 --- a/nix/checks/ssh-proxy.nix +++ b/nix/checks/ssh-proxy.nix @@ -20,6 +20,7 @@ let user = "root"; host = "ssh.example.com"; asOutbound = true; + serviceUser = "proxy"; identityFile = "/run/secrets/ssh-key"; knownHostsFile = "/run/secrets/ssh-known-hosts"; extraArgs = [ @@ -245,6 +246,10 @@ let assert pkgs.lib.hasInfix "ServerAliveInterval=30" sshStartScript; true ) + ( + assert sshService.serviceConfig.User == "proxy"; + true + ) ( assert !(sshService.serviceConfig ? SocketMark); true