mirror of
https://github.com/nmasur/dotfiles
synced 2025-07-06 19:00:14 +00:00
initial refactoring
This commit is contained in:
48
platforms/nixos/modules/nmasur/presets/services/openssh.nix
Normal file
48
platforms/nixos/modules/nmasur/presets/services/openssh.nix
Normal file
@ -0,0 +1,48 @@
|
||||
# SSHD service for allowing SSH access to my machines.
|
||||
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.nmasur.presets.services.openssh;
|
||||
in
|
||||
{
|
||||
|
||||
options.nmasur.presets.services.openssh = {
|
||||
enable = lib.mkEnableOption "OpenSSH remote access service";
|
||||
publicKeys = lib.mkOption {
|
||||
type = lib.types.nullOr (lib.types.listOf lib.types.str);
|
||||
description = "Public SSH keys authorized for this system.";
|
||||
default = null;
|
||||
};
|
||||
# permitRootLogin = lib.mkOption {
|
||||
# type = lib.types.str;
|
||||
# description = "Root login settings.";
|
||||
# default = "no";
|
||||
# };
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
ports = [ 22 ];
|
||||
allowSFTP = true;
|
||||
settings = {
|
||||
GatewayPorts = "no";
|
||||
X11Forwarding = false;
|
||||
PasswordAuthentication = false;
|
||||
PermitRootLogin = "no";
|
||||
};
|
||||
};
|
||||
|
||||
users.users.${config.user}.openssh.authorizedKeys.keys = lib.mkIf (
|
||||
cfg.publicKeys != null
|
||||
) cfg.publicKeys;
|
||||
|
||||
# Add terminfo for SSH from popular terminal emulators
|
||||
environment.enableAllTerminfo = true;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user