This question already has an answer here:

if the script was useradd ...............<new_user>; passwd <new_user>;. is there a way to put the new password in a script? I don't need to change or add an old password for an existing user. I need to enter a brand new password twice when prompted.

marked as duplicate by muru, Kusalananda Apr 14 at 17:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


openssl rand -base64 8 | passwd --stdin <new user>

Not the answer you're looking for? Browse other questions tagged or ask your own question.