fix: ldap auth

This commit is contained in:
2025-08-01 23:11:42 +02:00
parent 467ade9340
commit 7225a5e787

View File

@@ -7,7 +7,7 @@ let
-y ${config.sops.secrets.linuxbind-password.path} \ -y ${config.sops.secrets.linuxbind-password.path} \
-b "ou=users,dc=cloonar,dc=com" \ -b "ou=users,dc=cloonar,dc=com" \
"(uid=$1)" sshPublicKey \ "(uid=$1)" sshPublicKey \
| sed -n 's/^sshPublicKey: //p' | ${pkgs.gnused}/bin/sed -n 's/^sshPublicKey: //p'
''; '';
in in
{ {
@@ -46,19 +46,35 @@ in
}; };
security.pam.services.login.makeHomeDir = true; security.pam.services.login.makeHomeDir = true;
security.pam.services.sshd.makeHomeDir = true;
security.pam.services.sudo.makeHomeDir = true;
security.pam.services.systemd-user.makeHomeDir = true; security.pam.services.systemd-user.makeHomeDir = true;
systemd.tmpfiles.rules = [ systemd.tmpfiles.rules = [
"L /bin/bash - - - - /run/current-system/sw/bin/bash" "L /bin/bash - - - - /run/current-system/sw/bin/bash"
]; ];
environment.etc."ssh/ldap-authorized-keys" = {
source = ldapAuthorizedKeys;
mode = "0555"; # executable, not writable
};
services.openssh = { services.openssh = {
settings = { settings = {
AuthorizedKeysCommand = toString ldapAuthorizedKeys; AuthorizedKeysCommand = "/etc/ssh/ldap-authorized-keys";
AuthorizedKeysCommandUser = "nslcd"; # default is “nobody” :contentReference[oaicite:0]{index=0} AuthorizedKeysCommandUser = "nslcd"; # default is “nobody” :contentReference[oaicite:0]{index=0}
PubkeyAuthentication = "yes"; PubkeyAuthentication = "yes";
}; };
}; };
users.users.nslcd = {
isSystemUser = true;
group = "nslcd";
};
users.groups.nslcd = {};
sops.secrets.sssd-environment = {}; sops.secrets.sssd-environment = {};
sops.secrets.linuxbind-password = {}; sops.secrets.linuxbind-password = {
owner = "nslcd";
};
} }