dotfiles/modules/nixos/services/sshd.nix
Noah Masur e86b2f184f fix: cloudflare tunnel on tempest
requires openssh, but removing public key
2023-07-12 23:33:35 -04:00

39 lines
988 B
Nix

{ 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;
description = "Root login settings.";
default = "no";
};
};
config = lib.mkIf config.services.openssh.enable {
services.openssh = {
ports = [ 22 ];
allowSFTP = true;
settings = {
GatewayPorts = "no";
X11Forwarding = false;
PasswordAuthentication = false;
PermitRootLogin = config.permitRootLogin;
};
};
users.users.${config.user}.openssh.authorizedKeys.keys =
lib.mkIf (config.publicKey != null) [ config.publicKey ];
# Implement a simple fail2ban service for sshd
services.sshguard.enable = true;
# Add terminfo for SSH from popular terminal emulators
environment.enableAllTerminfo = true;
};
}