-1

When I add a user by -useradd command, if I go to /etc/shadow the password isn't encrypted, and therefore I cannot login to that user. How can I encrypt that password in shadow file?

David
  • 3,487
YaserMow
  • 304

1 Answers1

2

That is working as intended. If you want to set a password using the useradd command, you are supposed to give a hashed version of the password to useradd.

So if you provide your plain text password when the system validates that user's login it will fail since the stored password would not be the hashes version of the password you would expect it to have.

If you take a look the the useradd documentation:

-p, --password PASSWORD The encrypted password, as returned by crypt(3). The
    default is to disable the password. Note: This option is not recommended 
    because the password (or encrypted password) will be visible by users 
    listing the processes. You should make sure the password respects the
    system's password policy.

However you can solve that issue by running passwd yourusernameand typing the proper plaintext password what will result on the hashed password appearing on /etc/shadows hashes as it should always be.

guidola
  • 21