为什么无密码帐户在 PAM 中会过期?
Why does a passwordless account expire in PAM?
我们已经在 PAM 中设置了我们的帐户策略以遵循 RHEL7 STIG 准则 http://rhel7stig.readthedocs.io/en/latest/。我们确实有一些密码为空并使用 SSH 密钥登录的服务帐户。 60 天后,服务帐户密码将过期并被禁用。这不是我所期望的无密码帐户的行为,我不认为密码过期会适用于无密码帐户。我如何告诉 PAM 不要让无密码帐户过期?
在login.defs
PASS_MIN_DAYS 1
PASS_MAX_DAYS 60
PASS_WARN_AGE 7
FAIL_DELAY 4
在/etc/default/useradd
INACTIVE=0
因为系统不关心这些帐户是否有密码。您必须将 PASS_MAX_DAYS 设置为 99999 或任何适合这些帐户的值。
看来我需要将这些帐户创建为系统帐户。来自 useradd 手册页...
System users will be created with no aging information in /etc/shadow - https://linux.die.net/man/8/useradd
示例命令。
useradd testuser --system
如果您使用 Ansible,您可以在用户模块中指定系统。
- user:
name: testuser
group: testuser
system: yes
结果在 /etc/shadow 中可见。注意 testuser 没有密码最长期限条目。
[root@localhost ~]# useradd testuser --system
[root@localhost ~]# grep testuser /etc/shadow
testuser:!!:17417::::::
[root@localhost ~]# grep ryan /etc/shadow
ryan:*:18976:1:60:7:0::
PAM solution offers a secure, streamlined way to authorize and monitor
all privileged users for all relevant systems.
IT 团队通常共享 root、Windows 管理员和许多其他方便的特权凭据,以便可以根据需要无缝共享工作负载和职责。现在,多人共享相同的帐户密码会产生安全性、可审计性和合规性问题。特权帐户和凭据可能在不同的组织孤岛中以不同的方式进行管理,从而导致最佳实践的执行不一致。默认情况下,应用程序和服务帐户经常拥有过多的特权访问权限,并且还存在其他严重的安全缺陷。
- 解决方法可以是:“UsePAM no”
- 解决方法可以是:设置用户密码永不过期
- 您可能不想更改您的 PAM 或 sshd_config 合规性
原因。
- 您可能在 sshd_config
中使用 PasswordAuthentication no
- 您可能有随机密码。
- 您甚至可能已经实施了 CIS 合规性。
如果您的用户收到提示,那么 root 可以调整密码更改日期:
for user in `grep ":x:[0-9]\{4\}" /etc/passwd|cut -d: -f1`; do chage -d today $user;
附上一些参考资料:
- https://access.redhat.com/solutions/5447861
- https://documentation.suse.com/sles/15-SP2/html/SLES-all/sec-sec-user-management.html
最后的想法:
我认为我们需要对我们的帐户进行身份验证,以避免任何第 3 方或其他不相关的用户访问我们的数据和信息,因为我们可能拥有我们可能想要保护的机密数据,以免被不同的眼睛看到在网络上。
此外,如果您需要从另一个角度看我的答案,您可以看看这个答案()
我们已经在 PAM 中设置了我们的帐户策略以遵循 RHEL7 STIG 准则 http://rhel7stig.readthedocs.io/en/latest/。我们确实有一些密码为空并使用 SSH 密钥登录的服务帐户。 60 天后,服务帐户密码将过期并被禁用。这不是我所期望的无密码帐户的行为,我不认为密码过期会适用于无密码帐户。我如何告诉 PAM 不要让无密码帐户过期?
在login.defs
PASS_MIN_DAYS 1
PASS_MAX_DAYS 60
PASS_WARN_AGE 7
FAIL_DELAY 4
在/etc/default/useradd
INACTIVE=0
因为系统不关心这些帐户是否有密码。您必须将 PASS_MAX_DAYS 设置为 99999 或任何适合这些帐户的值。
看来我需要将这些帐户创建为系统帐户。来自 useradd 手册页...
System users will be created with no aging information in /etc/shadow - https://linux.die.net/man/8/useradd
示例命令。
useradd testuser --system
如果您使用 Ansible,您可以在用户模块中指定系统。
- user:
name: testuser
group: testuser
system: yes
结果在 /etc/shadow 中可见。注意 testuser 没有密码最长期限条目。
[root@localhost ~]# useradd testuser --system
[root@localhost ~]# grep testuser /etc/shadow
testuser:!!:17417::::::
[root@localhost ~]# grep ryan /etc/shadow
ryan:*:18976:1:60:7:0::
PAM solution offers a secure, streamlined way to authorize and monitor all privileged users for all relevant systems.
IT 团队通常共享 root、Windows 管理员和许多其他方便的特权凭据,以便可以根据需要无缝共享工作负载和职责。现在,多人共享相同的帐户密码会产生安全性、可审计性和合规性问题。特权帐户和凭据可能在不同的组织孤岛中以不同的方式进行管理,从而导致最佳实践的执行不一致。默认情况下,应用程序和服务帐户经常拥有过多的特权访问权限,并且还存在其他严重的安全缺陷。
- 解决方法可以是:“UsePAM no”
- 解决方法可以是:设置用户密码永不过期
- 您可能不想更改您的 PAM 或 sshd_config 合规性 原因。
- 您可能在 sshd_config 中使用 PasswordAuthentication no
- 您可能有随机密码。
- 您甚至可能已经实施了 CIS 合规性。
如果您的用户收到提示,那么 root 可以调整密码更改日期:
for user in `grep ":x:[0-9]\{4\}" /etc/passwd|cut -d: -f1`; do chage -d today $user;
附上一些参考资料:
- https://access.redhat.com/solutions/5447861
- https://documentation.suse.com/sles/15-SP2/html/SLES-all/sec-sec-user-management.html
最后的想法:
我认为我们需要对我们的帐户进行身份验证,以避免任何第 3 方或其他不相关的用户访问我们的数据和信息,因为我们可能拥有我们可能想要保护的机密数据,以免被不同的眼睛看到在网络上。
此外,如果您需要从另一个角度看我的答案,您可以看看这个答案(