refactor: move sudo to core, lxc SSH to profile, clean up old lxc config
- sudo (wheelNeedsPassword) → modules/core/core.nix (全局) - LXC SSH override (PermitRootLogin, PasswordAuth) → profiles/lxc.nix - modules/server/ssh.nix: use mkDefault so profiles can override - Delete modules/optional/lxc.nix - Clean up hosts/nixos-lxc/configuration.nix: remove redundant SSH/sudo/users (now handled by core + server + profile chain) - Update modules/optional/README.md
This commit is contained in:
@@ -21,32 +21,10 @@
|
|||||||
# 由宿主机处理 fstrim
|
# 由宿主机处理 fstrim
|
||||||
services.fstrim.enable = false;
|
services.fstrim.enable = false;
|
||||||
|
|
||||||
services.openssh = {
|
|
||||||
enable = true;
|
|
||||||
openFirewall = true;
|
|
||||||
settings = {
|
|
||||||
PermitRootLogin = "yes";
|
|
||||||
PasswordAuthentication = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# 用户账户配置
|
|
||||||
users.users.luochen570 = {
|
|
||||||
isNormalUser = true;
|
|
||||||
extraGroups = [ "wheel" "networkmanager" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
security.sudo.wheelNeedsPassword = false;
|
|
||||||
|
|
||||||
services.resolved = {
|
services.resolved = {
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
Cache=true
|
Cache=true
|
||||||
CacheFromLocalhost=true
|
CacheFromLocalhost=true
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
nix.settings.substituters = [ "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" ];
|
|
||||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
|
||||||
|
|
||||||
system.stateVersion = "25.05";
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,4 +24,7 @@
|
|||||||
time.timeZone = lib.mkDefault "Asia/Shanghai";
|
time.timeZone = lib.mkDefault "Asia/Shanghai";
|
||||||
i18n.defaultLocale = lib.mkDefault "zh_CN.UTF-8";
|
i18n.defaultLocale = lib.mkDefault "zh_CN.UTF-8";
|
||||||
|
|
||||||
|
# 允许 wheel 组免密 sudo
|
||||||
|
security.sudo.wheelNeedsPassword = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
{ ... }:
|
{ lib, ... }:
|
||||||
{
|
{
|
||||||
services.openssh = {
|
services.openssh = {
|
||||||
enable = true;
|
enable = true;
|
||||||
openFirewall = true;
|
openFirewall = true;
|
||||||
settings = {
|
settings = {
|
||||||
PasswordAuthentication = false;
|
PasswordAuthentication = lib.mkDefault false;
|
||||||
KbdInteractiveAuthentication = false;
|
KbdInteractiveAuthentication = lib.mkDefault false;
|
||||||
PermitRootLogin = "no";
|
PermitRootLogin = lib.mkDefault "no";
|
||||||
X11Forwarding = false;
|
X11Forwarding = lib.mkDefault false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,5 +2,13 @@
|
|||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
../modules/core
|
../modules/core
|
||||||
|
../modules/server
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# LXC 容器需要密码登录(s0.sermc.net,无 SSH key 注入)
|
||||||
|
services.openssh.settings = {
|
||||||
|
PermitRootLogin = "prohibit-password";
|
||||||
|
PasswordAuthentication = true;
|
||||||
|
KbdInteractiveAuthentication = true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user