linux使用者密碼策略測試

來源:互聯網
上載者:User

標籤:pam pam_cracklib


1、linux普通使用者預設密碼原則:

     用passwd修改使用者密碼,常常提示“BAD PASSWORD: it is based on a dictionary word”。實際上linux要求的密碼驗證機制是在/etc/login.defs中規定最小密碼字元數;同時還要受到/etc/pam.d/passwd的限定。但是在root使用者下怎麼設定都可以,可以不受驗證機制的約束,即便出來“BAD PASSWORD: it is based on a dictionary word”也可以修改成功。

     但是普通使用者修改自己的密碼,如果不符合密碼驗證機制的話就修改不成功,會有各種報錯。

“BAD PASSWORD: it‘s WAY too short”,這是報密碼太短,不符合/etc/login.defs的設定;

“BAD PASSWORD: it is based on your username”,這是密碼與帳號不能同名,這是不符合/etc/pam.d/passwd的設定;

“BAD PASSWORD: it is based on a dictionary word”這是因為出現了字典裡的字串。


如何去掉限制呢?

1. vi /etc/pam.d/system-auth as root.

2. Look for the following two lines:

password    requisite     pam_cracklib.so try_first_pass retry=3
password    sufficient    pam_unix.so md5 shadow nullok try_first_pass use_authtok

3. Comment out the first of the two lines:
#password    requisite     pam_cracklib.so try_first_pass retry=3

4. Remove use_authtok on the second line. Otherwise you’ll get “passwd: Authentication information cannot be recovered” error.
password    sufficient    pam_unix.so md5 shadow nullok try_first_pass

5. That’s it. Try changing your password again.

當只是操作第3步時,pam_cracklib.so密碼複雜度不檢查,但use_authtok依舊起作用,會導致所有無法修改密碼,則會出來如下報錯:

passwd: Authentication token manipulation error

按如上操作時,密碼複雜度不檢查,但普通使用者依舊受限於pam_cracklib的最短密碼長度。

Simple
           Is the new password too small? This is controlled by 6 arguments minlen, maxclassrepeat, dcredit, ucredit,lcredit, and ocredit. 


2、對普通使用者修改密碼,增加密碼安全性:

修改/etc/pam.d/system-auth

     password    requisite     pam_cracklib.so try_first_pass retry=3 minlen=8 lcredit=-1 ucredit=-1 ocredit=-1 dcredit=-1 enforce_for_root 

 

  其中enforce_for_root 是強制管理員修改,若無,管理員修改不受限制

  pam_cracklib.so模組,在centos6版本中有enforce_for_root,在5版本中無,可以使用pam_passwdqc.so


3、使用pam_passwdqc.so模組

          password    requisite  pam_passwdqc.so  enforce=everyone

   獨立於pam_cracklib模組,單獨設定密碼安全性。


本文出自 “秋天的童話” 部落格,請務必保留此出處http://wushank.blog.51cto.com/3489095/1662663

linux使用者密碼策略測試

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.