I want to know my /etc/shadow password hash if its SHA or MD or something else. From what I read, it is related to the $ sign, but I don't have any dollar signs.

Im using Ubuntu 16


  • 2
    Does this answer your question? How to find the hashing algorithm used to hash passwords? – Stephen Kitt Dec 15 '19 at 14:19
  • 5
    Is that an actual example or did you modify it? Because without the $n$ markers, it should be ye olde DES hash, but the length doesn't seem to match it (yours is 16 characters, and crypt() returns a string of 13 characters). I also wonder how a three-year old Ubuntu would end up using DES. What do you have in /etc/pam.d/common-password, on the line with pam_unix.so? Or in /etc/login.defs with ENCRYPT_METHOD? – ilkkachu Dec 15 '19 at 18:40
  • 1
    @ilkkachu that's not DES and DES hasn't been used for eons. The glibc crypt(3) functions does DES just for compat with dummy old games and such. The OP may be testing the waters, for all that I could guess ;-) – mosvy Dec 15 '19 at 19:34
  • @mosvy, well, like I said, the length doesn't match. Otherwise it looks like it could be a DES hash. Of course it hasn't been used for eons in any sensible system, but the support is still out there. At least chpasswd can be coerced to use it... That's why I wondered how they managed to get that hash. – ilkkachu Dec 15 '19 at 20:03
  • What's more DES can be written into /etc/passwd (instead of shadow). Support is definitely out there. – roaima Dec 23 '19 at 11:39

The shadow(5) manual on Ubuntu refers to the crypt(3) manual. The crypt(3) manual says that the default password encryption algorithm is DES.

It goes on to say that the glibc2 library function also supports MD5 and at least SHA-256 and SHA-512, but that an entry in /etc/shadow for a password encrypted by one of these algorithms would look like $1$salt$encrypted (for MD5), $5$salt$encrypted (for SHA-256), or $6$salt$encrypted (for SHA-512), where each $ is a literal $ character, where salt is a salt of up to 16 characters, and where encrypted is the actual hash.

Since your encrypted password does not follow that pattern, I'm assuming that it's encrypted using the default DES algorithm.

  • 7
    It might be worthwhile to mention that the DES password hash algorithm will only store passwords of up to 8 characters, and will ignore the rest. So if the actual password is longer than that, just getting the first 8 characters right will be enough. Even that alone might be reason enough to switch to another, more modern password hashing scheme. In Ubuntu, the password hash to use when changing a password is usually specified by options to pam_unix.so PAM module in /etc/pam.d/common-password. – telcoM Dec 15 '19 at 11:42

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.