0

Whenever I try to enter the password for a new user through pipe it doesn't work for me.. this is the command:

echo "${PASSWORD}" | passwd ${USER_NAME} 

However it fails to work, what am I missing? Thanks.

1 Answer 1

0

passwd doesn't support reading password from stdin in this fashion. Furthermore, it prompts for old password (if ran as user) and twice for new password. This can of course be scripted using expect.

2
  • There isn't any additional way? I'm not really familliar with the except syntax. I've seen someone typing --stdin with the passwd, however it doesn't work for me.. maybe not supported anymore I don't know.
    – Asaf
    May 9, 2021 at 14:59
  • The linked answer on SO contains more or less the complete script, so it should be possible to modify to your usecase.
    – vidarlo
    May 9, 2021 at 15:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .