libpam-pwquality:\r\n Installed: (none)\r\n Candidate: 1.4.0-2\r\n Version table:\r\n 1.4.0-2 500\r\n 500 http:\/\/ke.archive.ubuntu.com\/ubuntu bionic\/main amd64 Packages<\/code><\/pre>\nAs you can see from the output above, no PAM pwquality library is installed. Hence, if it is not installed, you can install it as shown below;<\/p>\n
apt install libpam-pwquality<\/code><\/pre>\nNow that we have the right module in place, let us see how to enforce password complexity policy on Ubuntu 18.04 with pam_pwquality<\/code> module. To enforce password complexity policy on Ubuntu 18.04, you need to edit the \/etc\/pam.d\/common-password<\/code> configuration file. However, make a copy of this file before you make any adjustments.<\/p>\ncp \/etc\/pam.d\/common-password \/etc\/pam.d\/common-password.original<\/code><\/pre>\nThere are different options that can be passed to the pam_pwquality<\/code> to enforce password complexity policy on Ubuntu 18.04. Some of the options that we are going to use in this guide include dcredit<\/strong><\/code>, ucredit<\/strong><\/code>, lcredit<\/code><\/strong>, ocredit<\/strong><\/code>, minlen<\/strong><\/code>, reject_username<\/strong><\/code>, enforce_for_root<\/strong><\/code>, retry<\/strong><\/code>.<\/p>\nOnce you have made the backup of the \/etc\/pam.d\/common-password<\/code> configuration file, open it for editing. Find the line below;<\/p>\npassword requisite pam_pwquality.so retry=3<\/code><\/pre>\nComment it and replace with the line below;<\/p>\n
password requisite pam_pwquality.so retry=3 minlen=8 difok=3 lcredit=-1 ucredit=-1 dcredit=-1 ocredit=-1 reject_username enforce_for_root<\/strong><\/code><\/pre>\nBelow is a description of the options used;<\/p>\n
retry=3<\/code>: This options sets a number of times you are prompted to enter a right password before the returning an error. This is set to 3 in this case.
\nminlen=8<\/strong><\/code>: Sets the minimum acceptable size for the new password.
\ndifok=3<\/strong><\/code>: Specifies the number of characters that should be similar to the characters in the previous password.
\nlcredit=-1<\/strong><\/code>: Sets the minimum number of lower case letters that the password should contain.
\nucredit=-1<\/strong><\/code>: Sets the minimum number of upper case letters on a password.
\ndcredit=-1<\/strong><\/code>: Sets the\u00a0minimum number of digits to be contained in a password.
\nocredit=-1<\/strong><\/code>: Set the minimum number of other symbols such as @, #, ! $ % etc on a password.
\nreject_username<\/strong><\/code>: Rejects the password if contains the name of the user in either straight or reversed form.
\nenforce_for_root<\/strong><\/code>: Ensures that even if it is the root user that is setting the password, the complexity policies should be enforced. This option is off by default which means that just the message about the failed check is printed but root can change the password anyway.<\/p>\nNote that when setting the password credits, the negative number sets the minimum value while the positive number sets the maximum values.<\/p>\n
If you need to see more options for enforcing password complexity, run man pam_pwquality<\/code>.<\/p>\nTest the Password Complexity enforcement<\/h3>\n
To test this, as a user amos, am going to try 3 password that doesn’t meet the requirements above (At least 8 characters, a digit, a lower case, a symbol and an upper case letter).<\/p>\n
amos@ubuntu18:~$ passwd\r\nChanging password for amos.\r\n(current) UNIX password: \r\nNew password: \r\nBAD PASSWORD: The password is too similar to the old one\r\nNew password: \r\nBAD PASSWORD: The password contains less than 1 digits\r\nNew password: \r\nBAD PASSWORD: The password contains less than 1 non-alphanumeric characters\r\npasswd: Have exhausted maximum number of retries for service\r\npasswd: password unchanged<\/code><\/pre>\nNext, am going to use a more complex password that meets the above defined policy: P@ssword1<\/code>.<\/p>\namos@ubuntu18:~$ passwd\r\nChanging password for amos.\r\n(current) UNIX password: amos123\r\nNew password: P@ssword1<\/code> Retype new password: P@ssword1<\/code> passwd: password updated successfully<\/code><\/pre>\nTest the password change as root<\/code> user.<\/p>\nroot@ubuntu18:~# passwd amos\r\nNew password: \r\nBAD PASSWORD: The password contains less than 1 uppercase letters\r\nNew password: \r\nBAD PASSWORD: The password contains less than 1 digits\r\nNew password: \r\nBAD PASSWORD: The password contains less than 1 non-alphanumeric characters\r\npasswd: Have exhausted maximum number of retries for service\r\npasswd: password unchanged<\/code><\/pre>\nroot@ubuntu18:~# passwd amos\r\nNew password: H@cker123\r\nRetype new password: H@cker123\r\npasswd: password updated successfully<\/code><\/pre>\nThat is it. That is all it takes to enforce password complexity policy on Ubuntu 18.04. We hope this was informative. Enjoy<\/p>\n","protected":false},"excerpt":{"rendered":"
Hello folks. Today, we are going to learn how to enforce password complexity policy on Ubuntu 18.04. As you realize, the traditional way of using<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[352,34],"tags":[354,356,353,67],"class_list":["post-2400","post","type-post","status-publish","format-standard","hentry","category-password-policies","category-security","tag-pam","tag-pam_pwquality","tag-password-complexity","tag-ubuntu-18-04","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2400"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=2400"}],"version-history":[{"count":5,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2400\/revisions"}],"predecessor-version":[{"id":2413,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2400\/revisions\/2413"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=2400"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=2400"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=2400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}