# what is the max length of password on unix/linux system?

what is the max permissible length of password on unix/linux system?

-

## migrated from stackoverflow.comJun 4 '10 at 21:59

This question came from our site for professional and enthusiast programmers.

If the answer isn't 42, it should be. – tvanfosson Jun 4 '10 at 21:55
a better question might be: what can I reasonably expect someone to type? If the limit is 40 and you are exceeding that, you are doing something wrong. – msw Jun 4 '10 at 23:40

There is a slight downside to using these hashes which is that a hash has a finite size for example an MD5 hash is 128 bit. This means that an MD5 hash only has 2^128 or 340,282,366,920,938,463,463,374,607,431,768,211,456 possible combinations. Now while that is a big number, what this means is that you can have what they call a hash collision where you have two different items or keys that produce the same hash. In theory, the larger the key size, the lower probability of a collision and the longer it should take to brute force a password but that is strictly evaluating the entropy and how long it CAN take but there is also a chance that the first entry they try can be the one which matches even if it's a hash collision. Generally speaking, you really are safer using a hash which has a larger key size because, suppose this is MD5, the odds of the first password matching out of 340,282,366,920,938,463,463,374,607,431,768,211,456 possible matches is extremely extremely unlikely. Also pick a good password because a lot of crackers will try and use word lists, name lists, and mutations of these list (i.e. if the word is "fish" then they will try fish1234, fish!@#\$ etc) before they rely on brute forcing a password.

So you know, the numbers mean this:

• \$1\$ means you are using MD5
• \$2\$ or \$2a\$ means you are using blowfish
• \$5\$ means you are using SHA-256
• \$6\$ means you are using SHA-512

SHA-512 is the best available hash to use that glibc offers. I don't know how strong blowfish is but it is not part of glibc and therefor is only available on certain distributions that have added it. SHA-512 produces 512 bit keys or 2^512 possible combinations before a collision can be expected and with a complex enough password, it would take a cluster of computers a very very long time to find either the actual password or a collision in the hash.

Also, if you have a hash which does not start with \$num\$ then you are using DES and that is limited to 8 character length. I believe older system that use DES, or at least some of them, they will take any size password but only use the first 8 character. This means if you set your password to mybigbigapple and someone uses the password mybigbigcity then they will be allowed in because DES will only use mybigbig and anything after that is discarded.

So you know, Ubuntu as of 8.04, which was released in April 2008, used MD5 hashes. Ubuntu from 8.10, which was released in October 2008, and all versions since then use SHA-512 hashes. I don't know how far before April 2008 but I believe for several years if not more, most all distributions used hashes.

Current 12.04 and 14.04 LTS (long term support releases) of Ubuntu appear to use SHA-512 by default, as can be seen with the \$6\$ prepended to the hash in the /etc/shadow file:

catullus:\$6\$MsHYK60sqcv\$BtDqVCMXibpqg[...]

Now the length the key or password allowed for any hashing algorithm isn't the only thing to determine what size password you are allowed to have. The other item of interest is how the program is written and what length program itself will support. All modern passwd programs and probably most the crypt(3) function in Linux. crypt for a long long (since at least MD5 was used and probably before that) has allowed character pointers for the actual key. This means that the only limit on how long of a key it will accept is based on how much RAM that program has available to it but in all likelyhood, this is probably far far far longer then any password any person would ever be able to remember (millions of characters?).

This should answer your question as to how long a password can be. Hope I helped.

References:

-
+1 for a fantastic answer. – Sathya Oct 22 '10 at 20:56
"What is the max length of a SU answer?" lol Great answer! – KronoS Oct 22 '10 at 20:57
It should be noted that the crypt() algorithm has been deprecated for over a decade. No matter how long a crypt() password is, it gets truncated to 8 characters. Combined with the very small keyspace of a 12bit salt, crypt() has been rendered entirely insecure. As a reference, here is an article on how 1million of Gawker's passwords were exposed due to the use of crypt() back in 2010: https://www.lightbluetouchpaper.org/2010/12/15/the-gawker-hack-how-a-million-pa‌​sswords-were-lost/ – cremefraiche Oct 26 '15 at 4:22

It depends on which authentication module is used. In modern Linux systems, there is no maximum limit on password length. Some obsolete systems might have limits imposed by their password storage system -- popular maximums seem to be 8, 40, and 255.

-

Depending on how the password is stored, MD5, SHA1, BlowFish etc I think there is no limit on password set by the storage method itself.

Older implementations might have a limit that is probably 8 or 255 characters.

This does seem like a question better suited for www.serverfault.com though :)

-
This is general computer related, not necessarily specific to servers though! – Darth Android Jun 4 '10 at 23:19