refactor: consolidate sshd enable + port 22 into modules/ssh.nix #51

Open
opened 2026-06-29 13:02:54 +01:00 by lyrathorpe · 0 comments
Owner

Problem

services.openssh.enable = true; together with networking.firewall.allowedTCPPorts = [ 22 ]; is repeated in each sshd host:

  • hosts/T400/configuration.nix
  • hosts/MacPro31/configuration.nix
  • hosts/RPi5/configuration.nix

modules/ssh.nix (imported by all three) currently only carries the hardening settings, not the enable/port.

Impact

Drift risk: the listening service and its firewall port are declared per-host instead of once, so they can diverge.

Suggested fix

Move services.openssh.enable = true; and networking.firewall.allowedTCPPorts = [ 22 ]; into modules/ssh.nix, so importing the module both hardens and enables sshd. Drop the per-host duplicates.

## Problem `services.openssh.enable = true;` together with `networking.firewall.allowedTCPPorts = [ 22 ];` is repeated in each sshd host: - `hosts/T400/configuration.nix` - `hosts/MacPro31/configuration.nix` - `hosts/RPi5/configuration.nix` `modules/ssh.nix` (imported by all three) currently only carries the hardening settings, not the enable/port. ## Impact Drift risk: the listening service and its firewall port are declared per-host instead of once, so they can diverge. ## Suggested fix Move `services.openssh.enable = true;` and `networking.firewall.allowedTCPPorts = [ 22 ];` into `modules/ssh.nix`, so importing the module both hardens and enables sshd. Drop the per-host duplicates.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: lyrathorpe/nixfiles#51