How are passwords generated that are used by Ubuntu 10.04? I know that they use SHA 512 as hashing algorithm, but I figure that there is some sort of salting done. I need to generate such a password myself. How can I do that? Is there a command line tool for that?


It should be trivial to hack up a quick python/perl/whatever script and call the crypt(3) function.

The glibc2 version of this function supports additional encryption algorithms.

If salt is a character string starting with the characters "$id$" followed by
a string terminated by "$":


then instead of using the DES machine, id identifies the encryption method
used and this then determines how the rest of the password string is
interpreted.  The following values of id are supported:

      ID  | Method
      1   | MD5
      2a  | Blowfish (not in mainline glibc; added in some
          | Linux distributions)
      5   | SHA-256 (since glibc 2.7)
      6   | SHA-512 (since glibc 2.7)

So $5$salt$encrypted is an SHA-256 encoded password and $6$salt$encrypted is
an SHA-512 encoded one.

"salt" stands for the up to 16 characters following "$id$" in the salt.  The
encrypted part of the password string is the actual computed password.  The
size of this string is fixed:

MD5     | 22 characters
SHA-256 | 43 characters
SHA-512 | 86 characters

The characters in "salt" and "encrypted" are drawn from the set [a-zA-Z0-9./].
In the MD5 and SHA implementations the entire key is significant (instead of
only the first 8 bytes in DES).

You can still use md5 passwords in the shadow file in systems that default to sha-512 or something else. The command like tool makepasswd can be used to generate a MD5 hash.

You can use the mkpasswd which strangely is part of the whois package on Debian/Ubuntu. mkpasswd -m sha-512. (Found here)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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