Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to set up minimum passcode requirements, such as a minimum length, requirement of mixed case alphanumerics and at least 1 symbol in the passcode, and enforce that at passcode changes?

share|improve this question
up vote 15 down vote accepted

Password complexity in Ubuntu is controlled by PAM. Unfortunately, PAM is "typically Unix" like in its approach. Meaning that it spreads its configuration through a large number of very confusing files.

The file that controls password complexity is:


There is a line:

password [success=1 default=ignore] obscure sha512

Which defines the basic rules for password complexity. You can add a minimum length override by changing it to:

password [success=1 default=ignore] obscure sha512 minlen=12

or whatever minimum you want. As you can see, the default already defines some basic obscurity rules. These basic rules can be seen in:

man pam_unix

Search for "obscure".

There are a large number of pam modules that can be installed.

apt-cache search libpam-

Should show you them.

You will need to hunt down the documenation for them I'm afraid. But the "cracklib" is a common addition.

UPDATE: I should have pointed out that the default "obscure" parameter includes tests for complexity based on previous passwords and simplicity (length, number of different types of character). The example in the manpage shows cracklib in action. Install libpam_cracklib to get that working.

Also, once you have worked out what to change, the changes are the same in other files so that you can enforce the same (or different) password checks for SSH and other applications.

share|improve this answer
Wonderful, thanks. – Thomas Ward Jun 28 '12 at 15:13

Password values are controlled in the file


For more information on how to modify the file see pam_unix manpage

share|improve this answer
You've listed pam_unix(5), the correct page is pam_unix(8) In fact, the online versions of the manpage, for some reason don't seem to list the important section on the "obscure" parameter - the one that I've included in my answer. If you do a man pam_unix, you will be able to see it though. – Julian Knight Jun 27 '12 at 20:57
@JulianKnight Thanks for the comment. I fixed the link :) – Mitch Jun 28 '12 at 5:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.