aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-04-03 10:21:20 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-04-03 10:28:10 +0200
commit7e6f1fb434797b4ffaf7eefa4a69825ce884fd20 (patch)
tree893278685ae318b918efbe474bd470a79df5d5af
parent33aa7e5c92daffce2f09639eb57cb995754fbd6b (diff)
downloadNix-7e6f1fb434797b4ffaf7eefa4a69825ce884fd20.tar.gz
Nix-7e6f1fb434797b4ffaf7eefa4a69825ce884fd20.tar.zst
Nix-7e6f1fb434797b4ffaf7eefa4a69825ce884fd20.zip
Move ssh to its own module
-rw-r--r--nixops/eldiron.nix33
-rw-r--r--nixops/modules/ssh/default.nix30
-rwxr-xr-xnixops/modules/ssh/ldap_authorized_keys.sh (renamed from nixops/ldap_authorized_keys.sh)0
3 files changed, 32 insertions, 31 deletions
diff --git a/nixops/eldiron.nix b/nixops/eldiron.nix
index 752ef0a..9d32bb3 100644
--- a/nixops/eldiron.nix
+++ b/nixops/eldiron.nix
@@ -6,7 +6,6 @@
6 }; 6 };
7 7
8 eldiron = { config, pkgs, mylibs, myconfig, ... }: 8 eldiron = { config, pkgs, mylibs, myconfig, ... }:
9 with mylibs;
10 { 9 {
11 _module.args = { 10 _module.args = {
12 pkgsNext = import <nixpkgsNext> {}; 11 pkgsNext = import <nixpkgsNext> {};
@@ -25,6 +24,7 @@
25 }; 24 };
26 25
27 imports = [ 26 imports = [
27 ./modules/ssh
28 ./modules/certificates.nix 28 ./modules/certificates.nix
29 ./modules/gitolite 29 ./modules/gitolite
30 ./modules/databases 30 ./modules/databases
@@ -52,12 +52,7 @@
52 MaxLevelStore="warning" 52 MaxLevelStore="warning"
53 MaxRetentionSec="1year" 53 MaxRetentionSec="1year"
54 ''; 54 '';
55 networking = { 55 networking.firewall.enable = true;
56 firewall = {
57 enable = true;
58 allowedTCPPorts = [ 22 ];
59 };
60 };
61 56
62 deployment = { 57 deployment = {
63 targetEnv = "hetzner"; 58 targetEnv = "hetzner";
@@ -85,30 +80,6 @@
85 pkgs.vim 80 pkgs.vim
86 ]; 81 ];
87 82
88 services.openssh.extraConfig = ''
89 AuthorizedKeysCommand /etc/ssh/ldap_authorized_keys
90 AuthorizedKeysCommandUser nobody
91 '';
92
93 environment.etc."ssh/ldap_authorized_keys" = let
94 ldap_authorized_keys =
95 wrap {
96 name = "ldap_authorized_keys";
97 file = ./ldap_authorized_keys.sh;
98 vars = {
99 LDAP_PASS = myconfig.env.sshd.ldap.password;
100 GITOLITE_SHELL = "${pkgs.gitolite}/bin/gitolite-shell";
101 ECHO = "${pkgs.coreutils}/bin/echo";
102 };
103 paths = [ pkgs.openldap pkgs.stdenv.shellPackage pkgs.gnugrep pkgs.gnused pkgs.coreutils ];
104 };
105 in {
106 enable = true;
107 mode = "0755";
108 user = "root";
109 source = ldap_authorized_keys;
110 };
111
112 services.cron = { 83 services.cron = {
113 enable = true; 84 enable = true;
114 systemCronJobs = [ 85 systemCronJobs = [
diff --git a/nixops/modules/ssh/default.nix b/nixops/modules/ssh/default.nix
new file mode 100644
index 0000000..b28f6ca
--- /dev/null
+++ b/nixops/modules/ssh/default.nix
@@ -0,0 +1,30 @@
1{ lib, pkgs, config, mylibs, myconfig, ... }:
2{
3 config = {
4 networking.firewall.allowedTCPPorts = [ 22 ];
5
6 services.openssh.extraConfig = ''
7 AuthorizedKeysCommand /etc/ssh/ldap_authorized_keys
8 AuthorizedKeysCommandUser nobody
9 '';
10
11 environment.etc."ssh/ldap_authorized_keys" = let
12 ldap_authorized_keys =
13 mylibs.wrap {
14 name = "ldap_authorized_keys";
15 file = ./ldap_authorized_keys.sh;
16 vars = {
17 LDAP_PASS = myconfig.env.sshd.ldap.password;
18 GITOLITE_SHELL = "${pkgs.gitolite}/bin/gitolite-shell";
19 ECHO = "${pkgs.coreutils}/bin/echo";
20 };
21 paths = [ pkgs.openldap pkgs.stdenv.shellPackage pkgs.gnugrep pkgs.gnused pkgs.coreutils ];
22 };
23 in {
24 enable = true;
25 mode = "0755";
26 user = "root";
27 source = ldap_authorized_keys;
28 };
29 };
30}
diff --git a/nixops/ldap_authorized_keys.sh b/nixops/modules/ssh/ldap_authorized_keys.sh
index d869d74..d869d74 100755
--- a/nixops/ldap_authorized_keys.sh
+++ b/nixops/modules/ssh/ldap_authorized_keys.sh