1

Doing:

# newusers
username::1002:1002::/home/username:/bin/bash
^D
No password supplied
No password supplied
No password supplied
newusers: (user username) pam_chauthtok() failed, error:
Authentication token manipulation error
newusers: (line 1, user username) password not changed

adds the user with no password (with hash "!" in /etc/shadow).

Doing:

# newusers
username:*:1002:1002::/home/username:/bin/bash
^D

adds the user with a password of "*" (with some hash in /etc/shadow).

However, what I need is to add that "username" user with a hash of "*" in /etc/shadow.

How do I do that?

1

Leave the password field blank. newusers will complain repeatedly about 'No password supplied' and being unable to change the password, but the users will be created with ! (i.e. invalid password) in the shadow password field.

username::1002:1002::/home/username:/bin/bash

instead of:

username:*:1002:1002::/home/username:/bin/bash

For example:

# echo "username::10000:10000::/home/username:/bin/bash" | newusers 
No password supplied
No password supplied
No password supplied
newusers: (user username) pam_chauthtok() failed, error:
Authentication token manipulation error
newusers: (line 1, user username) password not changed

# tail -1 /etc/passwd
username:x:10000:10000::/home/username:/bin/bash

# tail -1 /etc/shadow
username:!:16713:0:99999:7:::
| improve this answer | |
  • But, is ! the same as *? – tildearrow Oct 5 '15 at 5:19
  • yes. they're both invalid passwords. see man shadow and search for 'encrypted password': If the password field contains some string that is not a valid result of crypt(3), for instance ! or *, the user will not be able to use a unix password to log in (but the user may log in the system by other means). – cas Oct 5 '15 at 5:20
  • Doesn't work with rhel6 and rhel7, any pointers for those ? – coding_idiot Jun 27 '19 at 22:36
0

After adding your batch of users, you can unlock each user with the following command:

usermod -p <username> '*'
| improve this answer | |

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.