aboutsummaryrefslogtreecommitdiff
path: root/nixops/modules/ssh/default.nix
blob: b28f6cac6242cce8105529b19e81edb25b3f8dc2 (plain) (blame)
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
{ lib, pkgs, config, mylibs, myconfig, ... }:
{
  config = {
    networking.firewall.allowedTCPPorts = [ 22 ];

    services.openssh.extraConfig = ''
      AuthorizedKeysCommand     /etc/ssh/ldap_authorized_keys
      AuthorizedKeysCommandUser nobody
      '';

    environment.etc."ssh/ldap_authorized_keys" = let
      ldap_authorized_keys =
        mylibs.wrap {
          name = "ldap_authorized_keys";
          file = ./ldap_authorized_keys.sh;
          vars = {
            LDAP_PASS = myconfig.env.sshd.ldap.password;
            GITOLITE_SHELL = "${pkgs.gitolite}/bin/gitolite-shell";
            ECHO = "${pkgs.coreutils}/bin/echo";
          };
          paths = [ pkgs.openldap pkgs.stdenv.shellPackage pkgs.gnugrep pkgs.gnused pkgs.coreutils ];
        };
    in {
      enable = true;
      mode = "0755";
      user = "root";
      source = ldap_authorized_keys;
    };
  };
}