![/etc/pam.d/ ssh 和登录规则](https://linux22.com/image/163211/%2Fetc%2Fpam.d%2F%20ssh%20%E5%92%8C%E7%99%BB%E5%BD%95%E8%A7%84%E5%88%99.png)
在 中/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
我要求确定,因为我认为有时天真的注释行可能会干扰规则的流程。
完整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
答案1
pam_selinux.so
为 PAM 会话设置 SELinux 安全上下文。如果 SELinux 是残疾人,PAM模块不会有任何影响,可以删除。
请注意,如果 SELinux 位于宽容的模式 SELinux 规则仍然使用但不强制执行。删除pam_selinux.so
将导致进程在不正确的安全上下文中运行,这可能会在审核日志中生成大量 AVC 拒绝消息。
如果稍后启用 SELinux,pam_selinux.so
则需要处于 PAM 配置中,用户登录才能正常工作。
答案2
我认为,如果您不确切知道这意味着什么,那么在尝试删除 pam 配置中的 2 行之前,您可以在配置文件中简化很多事情。这是我的 2 美分,因为我对 pam 一无所知。