Move user configuration to sshusers.nix and automate configuration of users.
This commit is contained in:
parent
dd237481f5
commit
8d858ad3d8
|
@ -8,6 +8,7 @@
|
||||||
imports =
|
imports =
|
||||||
[ # Include the results of the hardware scan.
|
[ # Include the results of the hardware scan.
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
|
./sshusers.nix
|
||||||
./variables.nix
|
./variables.nix
|
||||||
./mailserver.nix
|
./mailserver.nix
|
||||||
];
|
];
|
||||||
|
@ -71,7 +72,11 @@
|
||||||
# List services that you want to enable:
|
# List services that you want to enable:
|
||||||
|
|
||||||
# Enable the OpenSSH daemon.
|
# Enable the OpenSSH daemon.
|
||||||
services.openssh.enable = true;
|
services.openssh = {
|
||||||
|
enable = true;
|
||||||
|
# Only allow login through pubkey
|
||||||
|
passwordAuthentication = false;
|
||||||
|
};
|
||||||
|
|
||||||
# Open ports in the firewall.
|
# Open ports in the firewall.
|
||||||
# networking.firewall.allowedTCPPorts = [ ... ];
|
# networking.firewall.allowedTCPPorts = [ ... ];
|
||||||
|
@ -79,22 +84,10 @@
|
||||||
# Or disable the firewall altogether.
|
# Or disable the firewall altogether.
|
||||||
# networking.firewall.enable = false;
|
# networking.firewall.enable = false;
|
||||||
|
|
||||||
users.extraUsers."Entil_Zha" = {
|
# User configuration for root.
|
||||||
isNormalUser = true;
|
# Other users are defined in sshusers.nix
|
||||||
extraGroups = [ "wheel" ];
|
|
||||||
openssh.authorizedKeys.keys = [
|
|
||||||
"ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAgEAzeqpZiYL+NFikGyVU7h+5nvAovlJBQfwQHE7mXkYVokHDCykHDUZfeR2HKARaGnCcYyvWHZeZPDJzQg05INRZyook82qKhqc/aICthP0dolr8ImYsilkbSPd1SttZWEsURVz8UO9NtM6n++04p6ArCRL4eZMzq8OeeGc+Vmyu4jRcsIA3t6kuXJ5FECmNn9YOmV8gX5WOzN0akPRwlE1XmBszU7r+OktYOmg4P7kJpmRoV8hR6zBtAcSjCuELJhE7aKGa2UnIoWzLMt5JV0JP4fPjbZxYpWmGxwLgIp/YXuJ/+xVwGTAjUXanqyV4RPpSNQa78CZ4g5rW7ak9xWN46ChWO9ishQDak2o6jdCli2Vjj32ap/snfDMiHylbbgpdmF2l8CTTo2GODfvKEZI1kzFz/Cfeky/uZzvvVjgbVUAwIFscFWyTpgnZibEA/H5xCkVxI+icFzQALgnBVY/75Jw8jrdUzcMDWNKjMaGhegXJAuIZXueDJTuxiZcAXXTWdPqQCTitQitE6Gf/gnijmtBBKT3uVk/ZBwhZH5GrBRNL+A3dlHAqGvl1SlajQtAzhaZmEp1yIeObhzXJKi41vHSOxfJzQDqQz0H2ljmAK6c/0bEyohxiQ3+/pIyvHG4hgSKWG8ng7Np2bD7xoWV7WgZBys3TsDZdeTu8xMyl7U="
|
|
||||||
];
|
|
||||||
};
|
|
||||||
users.extraUsers.root = {
|
users.extraUsers.root = {
|
||||||
hashedPassword = "!";
|
hashedPassword = "!";
|
||||||
openssh.authorizedKeys.keys = [
|
|
||||||
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAEAQCr2msBYPpr9RJ4rHcEyn0W0NMgUnOVO66FdEwXf0O7gBm37urOdVEIr/AcV1z5dzaOolMacW+rs3OyWWKBSjvAG9CRQ/KslUz/ucwBlVdnjNRtvDnbXh/VLFl62mF/4AWmV8CTFas9Uckcb7oauSJhx9PjwrkNs4pyz0wyMwMeUZ9dcjr/kho60aixTfdX9b3suZ8MQSwDagPeyjbFmGHNL1R0hY1fJZsyzBgGfNv9uaRAfxjWRzGb4G1e8AXnK/gG5bnifcDwWz4QQHDRZhW4/f4h/JE8+tBkiyZnsiULyDsCmg1waMeuKD/eweK5JyFpnaInctHJNEMBAC8RHakm2jgE3lLrHzglzhSu64vJeotbiZdbBcXLGQ4QIoFC6pATJ0LxQ5u3hXVGR6cvHNuFobD8tJUa8LCkAUfuA5m0OTbXxv8AId7aS/CSv504tG7v6r1q+wNQvGCpuzq4ykOSbj4hgdXFFfAOM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Ljq3+ClQA9C6pgu8xsidgDNZV+f8h6pEBTFH5bdhOvJVa3XdemlKKD5VxZdjPlgqrBBobVkCvvwucCXUqpcHRTaygwlQzWMUFonxdJF3sil+x5d9UtJyPt6CH8QHOVeTKe67TgS3b6LA0WscUGhSFqwaOGaNEiHWqCWj/mM6AdepWHuspW4mbSv2cUk5wxIXqj0JVqE5bY9iiRODpOpx2a3+XhSLA8JVgvm7JRY1+tG9/PwtsoSvv3/y3IPcQHYIfmYXw== openpgp:0x36379070 leo"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# This value determines the NixOS release with which your system is to be
|
# This value determines the NixOS release with which your system is to be
|
||||||
|
|
16
sshusers.nix
Normal file
16
sshusers.nix
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
sshkeys = pkgs.fetchFromGitHub {
|
||||||
|
owner = "freifunkhamburg";
|
||||||
|
"repo" = "ssh-keys";
|
||||||
|
rev = "70a8f1a4b8ddf921579986fb08b45050abeef2bc";
|
||||||
|
sha512 = "05p3ypg5imjxiswsspiix1l783w11ddby78bwjv0dnppbz8i4ddiy8fz70vcz4q2fbb94kwnk5zm7mz53h24z3j97xq9d485nmxinpq";
|
||||||
|
};
|
||||||
|
getpubkeys = user: builtins.readFile "${sshkeys}/${user}.pub";
|
||||||
|
mkuser = user: { name = user; isNormalUser = true; extraGroups = [ "wheel" ]; initialPassword = "test1234"; openssh.authorizedKeys.keys = [ (getpubkeys user) ]; };
|
||||||
|
mkusers = users: map (mkuser) users;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
users.users = mkusers [ "tokudan" "Entil_Zha" "alexander" ];
|
||||||
|
}
|
Loading…
Reference in a new issue