security: disable SSH X11 forwarding on servers, keep on desktops

This commit is contained in:
Ryan Yin
2026-08-26 18:14:43 +08:00
parent 212f45e2ca
commit 65ee1a001f
6 changed files with 36 additions and 1 deletions
+3 -1
View File
@@ -7,7 +7,9 @@
services.openssh = { services.openssh = {
enable = true; enable = true;
settings = { settings = {
X11Forwarding = true; # Secure by default: X11 forwarding off everywhere; desktops re-enable it
# in modules/nixos/desktop/ssh.nix (needed for GUI forwarding).
X11Forwarding = lib.mkDefault false;
# root user is used for remote deployment, so we need to allow it # root user is used for remote deployment, so we need to allow it
PermitRootLogin = "prohibit-password"; PermitRootLogin = "prohibit-password";
PasswordAuthentication = false; # disable password login PasswordAuthentication = false; # disable password login
+5
View File
@@ -0,0 +1,5 @@
{
# Desktops keep X11 forwarding (current behavior, needed for GUI forwarding);
# servers default to off (see modules/nixos/base/ssh.nix).
services.openssh.settings.X11Forwarding = true;
}
@@ -0,0 +1,7 @@
{
lib,
outputs,
}:
lib.genAttrs (builtins.attrNames outputs.nixosConfigurations) (
name: name == "ai-niri" || name == "shoukei-niri"
)
@@ -0,0 +1,7 @@
{
lib,
outputs,
}:
lib.genAttrs (builtins.attrNames outputs.nixosConfigurations) (
name: outputs.nixosConfigurations.${name}.config.services.openssh.settings.X11Forwarding
)
@@ -0,0 +1,7 @@
{
lib,
outputs,
}:
lib.genAttrs (builtins.attrNames outputs.nixosConfigurations) (
name: name == "ai-niri" || name == "shoukei-niri"
)
@@ -0,0 +1,7 @@
{
lib,
outputs,
}:
lib.genAttrs (builtins.attrNames outputs.nixosConfigurations) (
name: outputs.nixosConfigurations.${name}.config.services.openssh.settings.X11Forwarding
)