AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 966731
Accepted
NoNoNo
NoNoNo
Asked: 2019-05-11 06:59:17 +0800 CST2019-05-11 06:59:17 +0800 CST 2019-05-11 06:59:17 +0800 CST

PAM:多个 pam_pwquality 需要多次重复相同的密码

  • 772

在 RHEL7 服务器中,我必须实现两个可以描述为 PAM pam_pwquality 模块参数的密码策略:

  1. 密码必需 pam_pwquality.so try_first_pass local_users_only minlen=14
  2. 密码必需 pam_pwquality.so try_first_pass local_users_only dcredit=0 ucredit=0 ocredit=0 lcredit=0 minclass=3 maxsequence=1

此外,默认的 RHEL 7 PAM 配置已经包含以下 pam_pwquality 条目:

  1. 密码必需 pam_pwquality.so try_first_pass local_users_only retry=3

我需要将条目 3 的密码策略应用于所有用户,并将密码策略应用于名为 group1 和 group2 的两个不同的本地用户组。

为了应用这个要求,我在 /etc/pam.d/password-auth-ac 和 /etc/pam.d/system-auth-ac 默认 pam_pwquality 条目之后添加了以下代码(在这个问题中命名为 3.) :

password requisite pam_pwquality.so try_first_pass local_users_only minlen=14 # Default RHEL7 pam_pwquality.so entry
#BEGIN PWPOLICY 1
password [success=1 default=ignore] pam_succeed_if.so user notingroup group1
password    requisite     pam_pwquality.so try_first_pass local_users_only minlen=14 use_authtok
#END PWPOLICY 1


#BEGIN PWPOLICY 2
password [success=1 default=ignore] pam_succeed_if.so user notingroup group2
password    requisite     pam_pwquality.so try_first_pass local_users_only dcredit=0 ucredit=0 ocredit=0 lcredit=0 minclass=3 maxsequence=1 use_authtok
#END PWPOLICY 2

此配置按预期工作,但它的缺点是当用户(包括在 group1 和 group2 中)更改密码时,它需要重复多次,如以下示例所示:

[test@rhel7 ~]$ passwd 
Changing password for user test.
Changing password for test.
(current) UNIX password: 
New password: 
Retype new password: 
Retype new password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

我最后两个 pam_pwquality 条目中包含的选项“use_authtok”似乎被忽略了。

您知道此配置或实现这些要求的其他方法有什么问题吗?

pam
  • 1 1 个回答
  • 969 Views

1 个回答

  • Voted
  1. Best Answer
    Erik Ogan
    2019-10-10T07:15:10+08:002019-10-10T07:15:10+08:00

    这里的问题有两个:

    1. pam_pwquality旨在明确提示使用 进行密码验证pam_get_authtok_verify,并且use_authtok仅适用于pam_get_authtok_noverify.
    2. PAM 按顺序在堆栈中向下工作,因此您的所有用户都在第一行使用默认策略,我相信您的pam_succeed_if跳过并没有按照您认为的方式工作。

    我认为您可能想要颠倒顺序并添加并使用括号语法来实现您所追求的:

    ### Policy Group 1
    # If the user is in group 1, do nothing (and run the next module), 
    # otherwise skip to Group 2
    password [success=ignore default=1] pam_succeed_if.so user ingroup group1
    
    # If this module succeeds skip 3 modules: the two for Group 2 
    # and 1 for the default entry, otherwise fail the stack immediately. 
    # "die" matches the "requisite" in your original policy. If "required" is 
    # intended, change this to "bad"
    password [success=3      default=die]   pam_pwquality.so try_first_pass local_users_only minlen=14
    
    ### Policy Group 2
    # If the user is in group 2, do nothing (and run the next module), 
    # otherwise skip to the default entry
    password [success=ignore default=1] pam_succeed_if.so user ingroup group2
    
    # Similar to Group 1, except we only need to skip the default module entry on success
    password [success=1  default=die]   pam_pwquality.so try_first_pass local_users_only dcredit=0 ucredit=0 ocredit=0 lcredit=0 minclass=3 maxsequence=1 
    
    ### Default RHEL7 pam_pwquality.so entry
    password requisite          pam_pwquality.so try_first_pass local_users_only minlen=14
    
    ### This should be replaced with the stack responsible for managing passwords, if not the RHEL7 default
    password sufficient         pam_unix.so try_first_pass use_authtok nullok sha512 shadow
    

    对我来说,Group #1 的政策和默认政策似乎没有任何区别。假设这不是故意的,我相信如果您确实需要所有 3 个都不同,以上应该可以工作。

    另外:此解决方案假定 group1 和 group2 成员资格是互斥的。如果有人在两个组中,则 group1 优先。

    • 1

相关问题

  • 如何使用 PAM 限制用户的 telnet 登录?

  • 控制台用户被锁定 - pam 问题?

  • 如何在 Subversion 中使用 Linux 用户名和密码?

  • /etc/pam.d/login 与 /etc/pam.d/system-auth

  • Ubuntu linux 密码错误需要更长的时间

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve