找回密码
 注册
查看: 11|回复: 0

BAD PASSWORD: The password is shorter than 8 characters 设置密码复杂度

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2025-3-15 11:56:03 | 显示全部楼层 |阅读模式
( R* ~) G/ J# h4 l: b

2 Y6 V! H1 I- Necho nova:xxxx |chpasswd
& V* e) v3 i4 W4 TBAD PASSWORD: The password contains less than 3 character classes
- z# x; _! s. K4 r0 j2 X  ~% ~1 C. }; O/ `" i; Z1 `

; w/ F. v% P4 ABAD PASSWORD: The password is shorter than 8 characters ( K( S& ]! q% P1 A& G3 A3 d3 e

7 `' T9 |$ Q, ~/ d! x设置密码复杂度6 n9 A% v: ~3 q( k* _. [
# Y0 l  Q+ o, A2 h0 t  @: l( `
在CentOS下设置密码复杂度分为两步
/ d7 i$ D, w7 `6 P! {& Q3 a: J& i4 C1 U( R
(1)修改/etc/login.defs文件1 {1 d% N  l  b$ H0 L8 }8 @
vim /etc/login.defs
1 A1 s9 E# n; e* \6 |% L6 ?/ }7 Q* e, _  m( A3 Q0 z9 D

2 R* b3 \3 u( F6 D" Z; [PASS_MAX_DAYS   90        # 密码最长过期天数
- N" T& H) r) K( `1 pPASS_MIN_DAYS   80       # 密码最小过期天数
: D6 {: \8 Y0 s" n( OPASS_MIN_LEN   3     # 密码最小长度
: N8 ^! ]$ ]1 f0 ZPASS_WARN_AGE   7       # 密码过期警告天数8 b; D4 L& s! \0 M& b8 g( c3 q6 z
' t9 l0 ^8 N, i( u( l
(2)修改/etc/pam.d/system-auth文件6 K" |5 _; f1 g# z" R; x
( H0 K! L4 ~1 @7 D  L* z
vim /etc/pam.d/system-auth
( i2 s. x3 Q, S; P( C+ c在 password requisite pam_cracklib.so 一行换成如下内容:7 B# m9 Y* w& p/ M6 Y% N

0 B1 N1 U! o/ l& C: X! Z. Wpassword  requisite pam_cracklib.so retry=5  difok=3 minlen=10 ucredit=-1 lcredit=-3 dcredit=-3 dictpath=/usr/share/cracklib/pw_dict4 L6 k) b8 E( Y/ J8 V) Y6 {/ b

  `, `- n$ N- G- g, A参数含义:
( }, T# K2 o8 \4 w$ Q! u- \# k
. o& l2 d7 [1 y4 l$ _3 u1 N尝试次数:5 ;最少不同字符:3 ;最小密码长度:10 ;最少大写字母:1;最少小写字母:3 ;最少数字:3 ;字典位置:/usr/share/cracklib/pw_dict$ ^0 ~9 q- f/ k% V

/ C6 n4 s  W9 k( K3 v) {7 a ; T( [4 R6 A9 i0 a' o

: i* e( B7 l2 e7 y( \) y- T2 y" J* P配置实现
! U4 H6 p0 N4 ~
8 l, q2 L0 w# `" t3 k  X在/etc/pam.d/password-auth和/etc/pam.d/system-auth文件中password配置项的前两行添加如下配置内容:+ Z  ~5 S! r, b* Y5 |: Z  I

) V1 Y$ \# l7 q  ^password    requisite     pam_pwquality.so minlen=8 minclass=3 enforce_for_root try_first_pass local_users_only retry=3 dcredit=0 ucredit=0 lcredit=0 ocredit=0
9 q. K' u2 @2 C6 @password    required      pam_pwhistory.so use_authtok remember=5 enforce_for_root
' p3 C2 T1 G( j8 b0 i) _4 C
  D9 |' E8 e6 v& [6 e" Q2 B2 S( e3 E) n5 E

7 |: p* Y' E8 k5 ?) ~* v! d* n设置时报错才知道,应该是命令错误了。
; |' ~5 q: s7 j; {8 d5 n7 ~: x
- L2 A" J/ A' d( X  }echo 'xxxx' | passwd --stdin nova
+ B2 e3 j, `9 \Changing password for user nova.
5 w7 L; x" M1 W& ?' x6 `passwd: all authentication tokens updated successfully.) C8 h( p. S5 b& F; O1 Q/ }

. k5 {& d. J: v; Z6 k  ]' R  a' z1 Z* t& f

5 L: Z. z, w1 Z* ~. i, w! ?  {还是命令的问题
8 g! V' o, ^# H- C3 h
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 00:46 , Processed in 0.015396 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表