如何去掉Linux的密碼複雜度要求__Linux

來源:互聯網
上載者:User
一、準備工作安裝 PAM 的 cracklib 模組,cracklib 能提供額外的密碼檢查能力。Debian、Ubuntu 或 Linux Mint 系統上:1 $ sudo apt-get install libpam-cracklibCentOS、Fedora、RHEL 系統已經預設安裝了 cracklib PAM 模組,所以在這些系統上無需執行上面的操作。注意:此教程中的密碼原則只對非 root 使用者有效,對 root 使用者無效。二、禁止使用舊密碼找到同時有 “password” 和 “pam_unix.so” 欄位並且附加有 “remember=5” 的那行,它表示禁止使用最近用過的5個密碼(己使用過的密碼會被儲存在 /etc/security/opasswd 下面)。Debian、Ubuntu 或 Linux Mint 系統上:12 $ sudo vi /etc/pam.d/common-passwordpassword [success=1 default=ignore] pam_unix.so obscure sha512 remember=5CentOS、Fedora、RHEL 系統上:12 $ sudo vi /etc/pam.d/system-authpassword sufficient pamunix.so sha512 shadow nullok tryfirstpass useauthtok remember=5 三、設定最短密碼長度找到同時有 “password” 和 “pam_cracklib.so” 欄位並且附加有 “minlen=10” 的那行,它表示最小密碼長度為(10 - 類型數量)。這裡的 “類型數量” 表示不同的字元類型數量。PAM 提供4種類型符號作為密碼(大寫字母、小寫字母、數字和標點符號)。如果你的密碼同時用上了這4種類型的符號,並且 minlen 設為10,那麼最短的密碼長度允許是6個字元。Debian、Ubuntu 或 Linux Mint 系統上:12 $ sudo vi /etc/pam.d/common-passwordpassword requisite pam_cracklib.so retry=3 minlen=10 difok=3CentOS、Fedora、RHEL 系統上:12 $ sudo vi /etc/pam.d/system-authpassword requisite pam_cracklib.so retry=3 difok=3 minlen=10四、設定密碼複雜度找到同時有 “password” 和 “pam_cracklib.so” 欄位並且附加有 “ucredit=-1 lcredit=-2 dcredit=-1 ocredit=-1” 的那行,它表示密碼必須至少包含一個大寫字母(ucredit),兩個小寫字母(lcredit),一個數字(dcredit)和一個標點符號(ocredit)。Debian、Ubuntu 或 Linux Mint 系統上:12 $ sudo vi /etc/pam.d/common-passwordpassword requisite pam_cracklib.so retry=3 minlen=10 difok=3 ucredit=-1 lcredit=-2 dcredit=-1 ocredit=-1CentOS、Fedora、RHEL 系統上:12 $ sudo vi /etc/pam.d/system-authpassword requisite pam_cracklib.so retry=3 difok=3 minlen=10 ucredit=-1 lcredit=-2 dcredit=-1 ocredit=-1五、設定密碼到期期限編輯 /etc/login.defs 檔案,可以設定當前密碼的有效期間限,具體變數如下所示:12 $ sudo vi /etc/login.defsPASSMAXDAYS 150 PASSMINDAYS 0 PASSWARNAGE 7這些設定要求使用者每6個月改變他們的密碼,並且會提前7天提醒使用者密碼快到期了。如果想為每個使用者佈建不同的密碼期限,使用 chage 命令。下面的命令可以查看某個使用者的密碼限期:$ sudo chage -l xmoduloLast password change : Dec 30, 2013 Password expires : never Password inactive : never Account expires : never Minimum number of days between password change : 0 Maximum number of days between password change : 99999 Number of days of warning before password expires : 7預設情況下,使用者的密碼永不到期。下面的命令用於修改 xmodulo 使用者的密碼期限:1 $ sudo chage -E 6/30/2014 -m 5 -M 90 -I 30 -W 14 xmodulo上面的命令將密碼期限設為2014年6月3日。另外,修改密碼的最短周期為5天,最長周期為90天。密碼到期前14天會發送訊息提醒使用者,到期後帳號會被鎖住30天。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.