summaryrefslogtreecommitdiff
path: root/system/sshd.nix
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-06-26 13:26:37 -0400
committerFreya Murphy <freya@freyacat.org>2025-06-26 13:26:37 -0400
commitd94d620d2f393e274676a619b8a56f97f0ed7524 (patch)
tree9a71c00f90a93749a4db4abe823e87ea72bfec2a /system/sshd.nix
parentadd packages to wsl (diff)
downloaddotfiles-nix-d94d620d2f393e274676a619b8a56f97f0ed7524.tar.gz
dotfiles-nix-d94d620d2f393e274676a619b8a56f97f0ed7524.tar.bz2
dotfiles-nix-d94d620d2f393e274676a619b8a56f97f0ed7524.zip
make system config more modular
Diffstat (limited to 'system/sshd.nix')
-rw-r--r--system/sshd.nix55
1 files changed, 30 insertions, 25 deletions
diff --git a/system/sshd.nix b/system/sshd.nix
index 088bccb..a1ca2f2 100644
--- a/system/sshd.nix
+++ b/system/sshd.nix
@@ -1,35 +1,40 @@
{
+ lib,
config,
self,
...
-}: {
- # sshd
- services.openssh = {
- enable = true;
- ports = [22];
- settings = {
- PasswordAuthentication = false;
- KbdInteractiveAuthentication = false;
- UseDns = true;
- X11Forwarding = false;
- PermitRootLogin = "no";
+}: let
+ inherit (lib) mkIf;
+in {
+ config = mkIf config.network {
+ # sshd
+ services.openssh = {
+ enable = true;
+ ports = [22];
+ settings = {
+ PasswordAuthentication = false;
+ KbdInteractiveAuthentication = false;
+ UseDns = true;
+ X11Forwarding = false;
+ PermitRootLogin = "no";
+ };
};
- };
- # allow ssh port
- networking.firewall.allowedTCPPorts = [22];
+ # allow ssh port
+ networking.firewall.allowedTCPPorts = [22];
- # ban evil
- services.fail2ban = {
- enable = true;
- ignoreIP = [
- # freyanet
- "10.0.0.0/14"
- ];
- };
+ # ban evil
+ services.fail2ban = {
+ enable = true;
+ ignoreIP = [
+ # freyanet
+ "10.0.0.0/14"
+ ];
+ };
- # add authorized keys
- users.users.${config.user} = {
- openssh.authorizedKeys.keyFiles = self.lib.sshKeys;
+ # add authorized keys
+ users.users.${config.user} = {
+ openssh.authorizedKeys.keyFiles = self.lib.sshKeys;
+ };
};
}