add openssh authorized_keys

This commit is contained in:
Daniel Barlow 2023-03-10 23:13:32 +00:00
parent 2594239bbc
commit f2d1789ad7

View file

@ -42,6 +42,10 @@ in {
type = types.str; type = types.str;
default = "/bin/sh"; default = "/bin/sh";
}; };
openssh.authorizedKeys.keys = mkOption {
type = types.listOf types.str;
default = [];
};
}; };
}); });
}; };
@ -59,12 +63,27 @@ in {
}); });
}; };
}; };
config = { config =
filesystem = dir { let authorized_key_files =
etc = dir { lib.attrsets.mapAttrs
passwd = { file = passwd-file; }; (name: val: dir {
group = { file = group-file; }; ".ssh" = dir {
authorized_keys = {
type = "f";
mode = "0400";
file = lib.concatStringsSep
"\n" val.openssh.authorizedKeys.keys;
};
};
})
config.users;
in {
filesystem = dir {
etc = dir {
passwd = { file = passwd-file; };
group = { file = group-file; };
};
home = dir authorized_key_files;
}; };
}; };
};
} }