Khoi
Khoi

Reputation: 4635

linux bash shell: how to create user with username and password from file?

I'm clear about everything except how to set password using the script. Normally, I would write:

passwd username

And the terminal would prompt for password. How to read password from file instead?

Upvotes: 0

Views: 1467

Answers (1)

PleaseStand
PleaseStand

Reputation: 32082

You can use:

passwd --stdin username < filename

From passwd(1):

--stdin This option is used to indicate that passwd should read the new password from standard input, which can be a pipe.

Upvotes: 2

Related Questions