在/etc/pam.d/
,配置文件对于sshd
和login
有一些规则selinux
。当我不使用 selinux 时,我可以简单地禁用这些行吗?我想简化 pam 规则。
具体来说,这些行是:
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so close
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so open
我要求确定,因为我认为有时天真地注释行可能会干扰通过规则的 tte 流程。
完整sshd
配置如下:
# PAM configuration for the Secure Shell service
# Standard Un*x authentication.
@include common-auth
# Standard Un*x authorization.
@include common-account
# SELinux needs to be the first session rule. This ensures that any lingering context has been cleared.
# Without this it is possible that a module could execute code in the wrong domain.
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so close
# Set the loginuid process attribute.
session required pam_loginuid.so
# Create a new session keyring.
session optional pam_keyinit.so force revoke
# Standard Un*x session setup and teardown.
@include common-session
# Print the status of the user's mailbox upon successful login.
session optional pam_mail.so standard noenv # [1]
# Set up user limits from /etc/security/limits.conf.
session required pam_limits.so
# Read environment variables from /etc/environment and
# /etc/security/pam_env.conf.
session required pam_env.so # [1]
# In Debian 4.0 (etch), locale-related environment variables were moved to
# /etc/default/locale, so read that as well.
session required pam_env.so user_readenv=1 envfile=/etc/default/locale
# SELinux needs to intervene at login time to ensure that the process starts
# in the proper default security context. Only sessions which are intended
# to run in the user's context should be run after this.
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so open
# Standard Un*x password updating.
@include common-password
pam_selinux.so
为 PAM 会话设置 SELinux 安全上下文。如果 SELinux 被禁用,则 PAM 模块将没有任何影响,可以将其删除。请注意,如果 SELinux 处于许可模式,SELinux 规则仍会使用但不会强制执行。删除
pam_selinux.so
将导致进程在不正确的安全上下文中运行,这可能会在审计日志中生成大量 AVC 拒绝消息。如果稍后启用 SELinux,则
pam_selinux.so
需要在 PAM 配置中才能使用户登录正常工作。我认为如果您不确切知道这意味着什么,那么在尝试删除 pam config 中的 2 行之前,您可以在配置文件中简化很多事情。这是我的 2 美分,因为我对 pam 一无所知。