Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Linux 修改密碼提示 "based on a dictionary word" 解決方案

編輯:關於 Linux

普通使用者執行 passwd 修改密碼時,常遇到 BAD PASSWORD: it is based on a dictionary word 錯誤。本文解析驗證機制並提供解決辦法。

錯誤來源

Linux 密碼驗證由兩層把關:

  1. /etc/login.defs:定義最小長度等基本規則。
  2. /etc/pam.d/passwd:PAM 模組(如 pam_cracklib.so)執行複雜度檢查——字典詞、用戶名相似、過短等。

Root 使用者修改任何密碼可繞過檢查(仍會警告但允許);普通使用者修改自身密碼必須通過所有檢查。

常見錯誤對照

錯誤訊息原因對應設定
it's WAY too short長度不足/etc/login.defs
it is based on your username含用戶名/etc/pam.d/passwd
it is based on a dictionary word含字典詞/etc/pam.d/passwd (pam_cracklib)

快速解決:符合複雜度的密碼策略

採用 英文大小寫 + 數字 + 符號,長度 ≥ 8 字元,避免常見單詞、鍵盤排列(如 qwerty)、個人資訊。例:K7#mP2$v。

進階:調整 PAM 策略(需 root)

編輯 /etc/pam.d/passwd 或 /etc/pam.d/system-auth,修改 pam_cracklib.so 參數:

  • minlen=8 最小長度
  • dcredit=-1 至少 1 個數字
  • ucredit=-1 至少 1 個大寫
  • lcredit=-1 至少 1 個小寫
  • ocredit=-1 至少 1 個特殊字元
  • difok=3 與舊密碼至少 3 字元不同
  • dictpath=/path/to/dict 自訂字典(或移除字典檢查)

修改後即時生效,無需重啟。

修改密碼命令速查

  • 普通使用者:passwd
  • Root 修改指定使用者:passwd username

理解 PAM 機制,既能快速通過驗證,也能依安全需求調整策略平衡便利與強度。

Copyright © Windows教程網 All Rights Reserved