services.openssh.extraConfig configuration

Hello, how do I configure values in there?
My .nix file looks like this:

  services.openssh = {
  enable = true;
  settings.PasswordAuthentication = false;
  settings.KbdInteractiveAuthentication = false;
  settings.PermitRootLogin = "no";
  extraConfig = ''
Host 192.168.178.5
ServerAliveInterval 30
ServerAliveCountMax 6
    '';
  };

When I build my NixOS i receive the error:

/nix/store/2x56wijadcg0nlkbqmpgdkvnk2sps9m6-sshd.conf-validated: line 33: Bad configuration option: Host
/nix/store/2x56wijadcg0nlkbqmpgdkvnk2sps9m6-sshd.conf-validated: line 35: Bad configuration option: ServerAliveInterval
/nix/store/2x56wijadcg0nlkbqmpgdkvnk2sps9m6-sshd.conf-validated: line 37: Bad configuration option: ServerAliveCountMax
/nix/store/2x56wijadcg0nlkbqmpgdkvnk2sps9m6-sshd.conf-validated: terminating, 3 bad configuration options

The /nix/store/2x56wijadcg0nlkbqmpgdkvnk2sps9m6-sshd.conf-validated file is looking good. Thank you for your help.

services.openssh is for setting up sshd_config. Those configuration options only make sense in ssh_config. You want programs.ssh.extraConfig instead.

2 Likes