Files

34 lines
1.7 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ws_usernode 节点专有用户 sudoers 白名单(生产部署)
#
# 安装:将本文件复制为 /etc/sudoers.d/usernode 并执行 `visudo -c` 校验。
# 节点进程以 usernode 用户运行,仅允许以 root 执行固定命令(禁任意 shell),
# 命令参数由程序内强校验(pkg.ValidateSystemAccount 等),见 PLAN §9。
#
# 注意:以下命令路径基于 Debian/Ubuntu/usr/sbin、/usr/bin、/bin)。
# Alpine 为 /usr/sbin、/usr/bin、/bin;请按发行版调整,并确保 usernode
# 用户无 NOPASSWD 的通用提权入口。
usernode ALL=(root) NOPASSWD: /usr/sbin/useradd, /usr/sbin/usermod, \
/usr/sbin/userdel, /usr/bin/passwd, \
/bin/mkdir, /bin/chmod, /bin/chown, /usr/bin/install
# 说明:
# - useradd -m -d <home> -s <shell> -g external <name> 创建账号
# - usermod 预留(如 usermod -e 过期),M4 回收期使用
# - userdel -r <name> 删除账号及家目录
# - passwd -l / -u <name> 锁定/解锁口令
# - mkdir -p / chown / chmod:创建并修正 ~/.ssh 目录属主(sshd StrictModes
# - install -o <user> -g external -m 0600 <tmp> <dest>authorized_keys 原子落位
# - 不授予 chsh/其他命令的任意执行;若需变更默认 shell 请收紧为固定参数
#
# 生产禁止 system.sudo=false 的 direct 模式:必须显式配置
# [system]
# sudo = true
# dry_run = false
#
# 审计命令行为:如需记录 usernode 用户经 sudo 执行的所有命令,可追加
# Defaults:usernode log_output
# 并把输出目录设为 usernode 可写(如 /var/log/usernode/sudo),配合
# journald 的 audit 日志作为系统账号操作的可追溯记录(PLAN §9)。