Compare commits

...

2 Commits

Author SHA1 Message Date
Jan-Bulthuis
0cf53a97cf Restricted SSH access 2025-05-30 16:15:52 +02:00
Jan-Bulthuis
46fe5b8056 Set local password 2025-05-30 16:15:42 +02:00
2 changed files with 22 additions and 15 deletions

View File

@ -9,10 +9,14 @@ in
enable = mkEnableOption "ssh"; enable = mkEnableOption "ssh";
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
services.openssh.enable = true; services.openssh = {
# TODO: Is this default configuration secure? enable = true;
settings = {
services.openssh.hostKeys = mkIf (config.modules.impermanence.enable) [ PasswordAuthentication = false;
KbdInteractiveAuthentication = false;
PermitRootLogin = "no";
};
hostKeys = mkIf (config.modules.impermanence.enable) [
{ {
type = "ed25519"; type = "ed25519";
path = "/persist/system/etc/ssh/ssh_host_ed25519_key"; path = "/persist/system/etc/ssh/ssh_host_ed25519_key";
@ -24,4 +28,5 @@ in
} }
]; ];
}; };
};
} }

View File

@ -33,7 +33,8 @@ in
}; };
# Local user # Local user
sops.secrets."ssh-keys/admin-pub" = { }; modules.secrets.secrets."ssh-keys/admin-pub" = { };
modules.secrets.secrets."passwords/local-hashed".neededForUsers = true;
services.getty.autologinUser = "local"; services.getty.autologinUser = "local";
security.sudo.extraRules = [ security.sudo.extraRules = [
{ {
@ -43,6 +44,7 @@ in
]; ];
users.mutableUsers = false; users.mutableUsers = false;
users.users.local = { users.users.local = {
hashedPasswordFile = config.sops.secrets."passwords/local-hashed".path;
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];
openssh.authorizedKeys.keyFiles = [ openssh.authorizedKeys.keyFiles = [
config.sops.secrets."ssh-keys/admin-pub".path config.sops.secrets."ssh-keys/admin-pub".path