List of allowable Linux password characters

Sadly, I have been doing Linux Administration for a short while and I still have NO idea where to find a comprehensive list of allowable characters for a linux password. My guess is that this may be because the configuration might be different on different systems depending on the configuration, for example: passwd file vs Open LDAP. Is there any comprehensive list of allowed Linux credentials when using authz/passwd/shadow files?


Solution 1:

Anything you can type is fair game in a standard Unix password - I'm not aware of any Linux-specific restrictions. With the caveat that a newline (Return/Enter) usually ends password input, any character you see on your keyboard is fair game.

Special keys are also allowed (arrow keys, function keys, page up/page down), as are some things you CAN'T type (you can go ahead and put a vertical tab in your password if you want to - it's just going to be VERY inconvenient to use that to log in unless you can cut and paste the character).
Be aware that these keys/characters may not work the same over a network connection as they do on a console though -- typically they aren't used for that reason.


The one "special case" I'm aware of is that a NUL character (ASCII 0) would probably be interpreted as "END OF STRING" and anything after that in your password might be discarded.

Solution 2:

It will help if you can provide your Linux distribution. This can be defined per system and as you rightly point out if something like LDAP is in place it may be defined there.

If using pam_cracklib(8), this is defined in /etc/pam.d/system-auth on Red Hat/CentOS/Fedora systems. If defined you should see something like this:

password required pam_cracklib.so minlen=12 lcredit=1 ucredit=1 dcredit=2 ocredit=1

On Ubuntu systems this would be under /etc/pam.d/common-password. See https://askubuntu.com/questions/156850/setting-minimum-password-requirements