mail2-nixos-config/sshusers.nix

36 lines
1.3 KiB
Nix
Raw Permalink Normal View History

{ lib, pkgs, ... }:
2019-06-10 14:45:38 +02:00
# Setup users. To add a new user:
# 1. Add the name of the user to the list in the second-to-last line
# 2. Make sure that the git repo contains the key as "$USER.pub"
2019-06-14 21:14:12 +02:00
# 3. Make sure that the commit ("rev") contains the latest commit hash. If it correct, jump to step 7.
2019-06-10 14:45:38 +02:00
# 4. If you changed the commit, manipulate the sha512 entry by changing the first character from 0 to 1 or 1 to 0.
# 5. Run "nixos-rebuild build"
# 6. Wait for a message about an invalid hash and replace the hash in this file with the new one.
# 7. Run "nixos-rebuild switch"
# 8. Let the user login and change their password
let
2024-04-05 20:49:47 +02:00
sshkeys = pkgs.fetchFromGitea {
domain = "git.hamburg.ccc.de";
owner = "freifunk";
2019-06-10 14:45:56 +02:00
repo = "ssh-keys";
2024-04-05 21:00:59 +02:00
rev = "6809bee81417ecbcc2f8333a234de9d41b8847cf";
hash = "sha512-J5jg0U2KN00yvdozfwl9DQFyhhGY7n6wuOeandse+U34J+Ume0y3pOtk51EoWVEqWL41ptGZVcvJhhOWbIBmUw==";
};
getpubkeys = user: builtins.readFile "${sshkeys}/${user}.pub";
mkuser = user: {
name = user;
isNormalUser = true;
extraGroups = [ "wheel" ];
createHome = true;
initialPassword = "test1234";
openssh.authorizedKeys.keys = (
lib.splitString "\n" (getpubkeys user)
);
};
in
{
users.users = (lib.genAttrs [ "tokudan" "Entil_Zha" "alexander" "kantorkel" "djerun" "nico22" ] mkuser);
}