It seems in Linux passwords are stored in the file /etc/shadow , or rather the passwords themselves are not stored, but their hashes.

What hashing algorithm is used for this? If it depends on the distribution, then how do I know which hashing algorithm is used in my distribution?

1 answer 1

the default hashing method is defined in the /etc/login.defs file

 $ grep '^ENCRYPT_METHOD' /etc/login.defs ENCRYPT_METHOD SHA512 

it can be redefined in the pam configuration files (of course, for those programs that use it). For example, in the debian gnu / linux distribution there is a configuration directive:

 $ grep -r '^password.*pam_unix' /etc/pam.d/ /etc/pam.d/common-password:password [success=1 default=ignore] pam_unix.so obscure sha512 

in this example, the method is the same as that defined in /etc/login.defs - sha512 .


but these directives will only affect the hashes of new passwords. already existing (or manually entered) can use any other method.