mirror of
https://github.com/nmasur/dotfiles
synced 2025-07-05 20:50:15 +00:00
clean up host settings
and start removing if statements
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
{ config, lib, ... }: {
|
||||
|
||||
options = {
|
||||
publicKey = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
description = "Public SSH key authorized for this system.";
|
||||
default = null;
|
||||
};
|
||||
permitRootLogin = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
@ -12,28 +13,27 @@
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf
|
||||
(pkgs.stdenv.isLinux && !config.wsl.enable && config.publicKey != null) {
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
ports = [ 22 ];
|
||||
allowSFTP = true;
|
||||
settings = {
|
||||
GatewayPorts = "no";
|
||||
X11Forwarding = false;
|
||||
PasswordAuthentication = false;
|
||||
PermitRootLogin = config.permitRootLogin;
|
||||
};
|
||||
config = lib.mkIf (!config.wsl.enable && config.publicKey != null) {
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
ports = [ 22 ];
|
||||
allowSFTP = true;
|
||||
settings = {
|
||||
GatewayPorts = "no";
|
||||
X11Forwarding = false;
|
||||
PasswordAuthentication = false;
|
||||
PermitRootLogin = config.permitRootLogin;
|
||||
};
|
||||
|
||||
users.users.${config.user}.openssh.authorizedKeys.keys =
|
||||
[ config.publicKey ];
|
||||
|
||||
# Implement a simple fail2ban service for sshd
|
||||
services.sshguard.enable = true;
|
||||
|
||||
# Add terminfo for SSH from popular terminal emulators
|
||||
environment.enableAllTerminfo = true;
|
||||
};
|
||||
|
||||
users.users.${config.user}.openssh.authorizedKeys.keys =
|
||||
[ config.publicKey ];
|
||||
|
||||
# Implement a simple fail2ban service for sshd
|
||||
services.sshguard.enable = true;
|
||||
|
||||
# Add terminfo for SSH from popular terminal emulators
|
||||
environment.enableAllTerminfo = true;
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user