···
else pkgs.buildPackages.openssh;
# reports boolean as yes / no
16
-
mkValueStringSshd = v:
16
+
mkValueStringSshd = with lib; v:
if isInt v then toString v
else if isString v then v
else if true == v then "yes"
else if false == v then "no"
21
+
else if isList v then concatStringsSep "," v
else throw "unsupported type ${typeOf v}: ${(lib.generators.toPretty {}) v}";
# dont use the "=" operator
···
(mkRenamedOptionModule [ "services" "openssh" "useDns" ] [ "services" "openssh" "settings" "UseDns" ])
(mkRenamedOptionModule [ "services" "openssh" "permitRootLogin" ] [ "services" "openssh" "settings" "PermitRootLogin" ])
(mkRenamedOptionModule [ "services" "openssh" "logLevel" ] [ "services" "openssh" "settings" "LogLevel" ])
108
+
(mkRenamedOptionModule [ "services" "openssh" "macs" ] [ "services" "openssh" "settings" "Macs" ])
109
+
(mkRenamedOptionModule [ "services" "openssh" "cyphers" ] [ "services" "openssh" "settings" "Cyphers" ])
110
+
(mkRenamedOptionModule [ "services" "openssh" "kexAlgorithms" ] [ "services" "openssh" "settings" "KexAlgorithms" ])
111
+
(mkRenamedOptionModule [ "services" "openssh" "gatewayPorts" ] [ "services" "openssh" "settings" "GatewayPorts" ])
112
+
(mkRenamedOptionModule [ "services" "openssh" "forwardX11" ] [ "services" "openssh" "settings" "X11Forwarding" ])
···
134
-
forwardX11 = mkOption {
137
-
description = lib.mdDoc ''
138
-
Whether to allow X11 connections to be forwarded.
···
170
-
gatewayPorts = mkOption {
173
-
description = lib.mdDoc ''
174
-
Specifies whether remote hosts are allowed to connect to
175
-
ports forwarded for the client. See
176
-
{manpage}`sshd_config(5)`.
type = types.listOf types.port;
···
289
-
kexAlgorithms = mkOption {
290
-
type = types.listOf types.str;
292
-
"sntrup761x25519-sha512@openssh.com"
293
-
"curve25519-sha256"
294
-
"curve25519-sha256@libssh.org"
295
-
"diffie-hellman-group-exchange-sha256"
297
-
description = lib.mdDoc ''
298
-
Allowed key exchange algorithms
300
-
Uses the lower bound recommended in both
301
-
<https://stribika.github.io/2015/01/04/secure-secure-shell.html>
303
-
<https://infosec.mozilla.org/guidelines/openssh#modern-openssh-67>
307
-
ciphers = mkOption {
308
-
type = types.listOf types.str;
310
-
"chacha20-poly1305@openssh.com"
311
-
"aes256-gcm@openssh.com"
312
-
"aes128-gcm@openssh.com"
317
-
description = lib.mdDoc ''
320
-
Defaults to recommended settings from both
321
-
<https://stribika.github.io/2015/01/04/secure-secure-shell.html>
323
-
<https://infosec.mozilla.org/guidelines/openssh#modern-openssh-67>
328
-
type = types.listOf types.str;
330
-
"hmac-sha2-512-etm@openssh.com"
331
-
"hmac-sha2-256-etm@openssh.com"
332
-
"umac-128-etm@openssh.com"
335
-
"umac-128@openssh.com"
337
-
description = lib.mdDoc ''
340
-
Defaults to recommended settings from both
341
-
<https://stribika.github.io/2015/01/04/secure-secure-shell.html>
343
-
<https://infosec.mozilla.org/guidelines/openssh#modern-openssh-67>
···
~/.ssh/authorized_keys from and sshd_config Match Host directives.
308
+
X11Forwarding = mkOption {
311
+
description = lib.mdDoc ''
312
+
Whether to allow X11 connections to be forwarded.
PasswordAuthentication = mkOption {
···
description = lib.mdDoc ''
Specifies whether keyboard-interactive authentication is allowed.
336
+
GatewayPorts = mkOption {
339
+
description = lib.mdDoc ''
340
+
Specifies whether remote hosts are allowed to connect to
341
+
ports forwarded for the client. See
342
+
{manpage}`sshd_config(5)`.
345
+
KexAlgorithms = mkOption {
346
+
type = types.listOf types.str;
348
+
"sntrup761x25519-sha512@openssh.com"
349
+
"curve25519-sha256"
350
+
"curve25519-sha256@libssh.org"
351
+
"diffie-hellman-group-exchange-sha256"
353
+
description = lib.mdDoc ''
354
+
Allowed key exchange algorithms
356
+
Uses the lower bound recommended in both
357
+
<https://stribika.github.io/2015/01/04/secure-secure-shell.html>
359
+
<https://infosec.mozilla.org/guidelines/openssh#modern-openssh-67>
363
+
type = types.listOf types.str;
365
+
"hmac-sha2-512-etm@openssh.com"
366
+
"hmac-sha2-256-etm@openssh.com"
367
+
"umac-128-etm@openssh.com"
370
+
"umac-128@openssh.com"
372
+
description = lib.mdDoc ''
375
+
Defaults to recommended settings from both
376
+
<https://stribika.github.io/2015/01/04/secure-secure-shell.html>
378
+
<https://infosec.mozilla.org/guidelines/openssh#modern-openssh-67>
381
+
Ciphers = mkOption {
382
+
type = types.listOf types.str;
384
+
"chacha20-poly1305@openssh.com"
385
+
"aes256-gcm@openssh.com"
386
+
"aes128-gcm@openssh.com"
391
+
description = lib.mdDoc ''
394
+
Defaults to recommended settings from both
395
+
<https://stribika.github.io/2015/01/04/secure-secure-shell.html>
397
+
<https://infosec.mozilla.org/guidelines/openssh#modern-openssh-67>
···
${optionalString cfgc.setXAuthLocation ''
XAuthLocation ${pkgs.xorg.xauth}/bin/xauth
559
-
X11Forwarding ${if cfg.forwardX11 then "yes" else "no"}
${optionalString cfg.allowSFTP ''
Subsystem sftp ${cfg.sftpServerExecutable} ${concatStringsSep " " cfg.sftpFlags}
565
-
GatewayPorts ${cfg.gatewayPorts}
PrintMotd no # handled by pam_motd
AuthorizedKeysFile ${toString cfg.authorizedKeysFiles}
${optionalString (cfg.authorizedKeysCommand != "none") ''
AuthorizedKeysCommand ${cfg.authorizedKeysCommand}
···
${flip concatMapStrings cfg.hostKeys (k: ''
579
-
KexAlgorithms ${concatStringsSep "," cfg.kexAlgorithms}
580
-
Ciphers ${concatStringsSep "," cfg.ciphers}
581
-
MACs ${concatStringsSep "," cfg.macs}
584
-
assertions = [{ assertion = if cfg.forwardX11 then cfgc.setXAuthLocation else true;
574
+
assertions = [{ assertion = if cfg.settings.X11Forwarding then cfgc.setXAuthLocation else true;
message = "cannot enable X11 forwarding without setting xauth location";}]
++ forEach cfg.listenAddresses ({ addr, ... }: {
assertion = addr != null;