summaryrefslogtreecommitdiff
path: root/nixos/modules/services/ssh.nix
blob: f32599a4bf8bbcd57ecd5949b9ba9388d3e5d284 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{ config, lib, pkgs, ... }:
with lib;

let
  cfg = config.eth.services.ssh;

in {
  options.eth.services.ssh = {
    enable = mkEnableOption "Whether to enable SSHd with Eth's defaults.";

    passwordAuthentication = mkOption {
      type = types.bool;
      default = false;
      description = "Whether to allow password authentication. Occasionally useful, used sparingly.";
    };

    sshAgentAuth = mkOption {
      type = types.bool;
      default = false;
      description = "Whether to enable sudo authentication using ssh-agent.";
    };
  };

  config = mkIf cfg.enable {

    security.pam.enableSSHAgentAuth = cfg.sshAgentAuth;
    security.pam.services.sudo.sshAgentAuth = cfg.sshAgentAuth;

    services.openssh = {
      enable = true;
      permitRootLogin = "no";
      passwordAuthentication = cfg.passwordAuthentication;
    };
  };
}