Unix_chkpwd[21]: password check failed for user (test)

I am trying to add test user with sudo in fresh Fedora container, and get this error. What is going on here?

# adduser test -p 12345678 -G wheel
# sudo -u test sudo echo Hello

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

For security reasons, the password you type will not be visible.

[sudo] password for test: 
unix_chkpwd[21]: password check failed for user (test)
Sorry, try again.

# passwd -S test for account status.

  • L - Locked
  • NP - No password set
  • P - Password set and active

Did you try:

  • sudo adduser test
  • sudo passwd test
  • sudo usermod -aG wheel test
    ?

I think -p option of adduser command expects a hashed password, so you could do:

PASSWORD_HASH=$(openssl passwd -6 12345678)
sudo adduser test -p "$PASSWORD_HASH" -G wheel
1 Like

status shows P, so should be ok.

# passwd --status test
test P 2024-12-16 0 99999 7 -1

adduser -p indeed expects hash of the password.

The encrypted password, as returned by crypt(3).

Installing openssl to get the password hash seems like an overkill to me.

This oneliner works.

adduser test -G wheel && echo 12345678 | passwd test --stdin

But it gives weird error message.

/usr/share/cracklib/pw_dict.pwd.gz: No such file or directory
BAD PASSWORD: The password fails the dictionary check - error loading dictionary

Not ideal, but at least sudo works.

# sudo -u test sudo echo Hello
[sudo] password for test: 
Hello