Linux – How does Linux verify the login password

linuxpasswordshadow

I would like to know how the password verification in Linux works.

I know that the passwords are stored as a hash in /etc/shadow file and user information is in /etc/passwd file. My understanding is this:

  1. Selecting what user you want to login as decides what user name the system should check.
  2. When you enter the password and hit enter, the system goes to the /etc/shadow file and finds the line corresponding to the user name.
  3. From step 2 it gets the hash of the actual password. It then generates the hash of the entered password and compares both of them. If a match is found, voilĂ . Else, error message.

Is my understanding correct?

Best Answer

Yes. You're correct. Each steps can be split in minor tasks as well, but you describe the overall algorithm.

Follow a couple of articles describing in details the login process. [1] [2]

Note that this is only about the plain password, not mentioning PAM system. [3]

Related Question