How to automatically add user account *and* password with a Bash script

Posted by ModernCarpentry on Stack Overflow See other posts from Stack Overflow or by ModernCarpentry
Published on 2010-01-27T22:43:45Z Indexed on 2010/05/29 23:32 UTC
Read the original article Hit count: 425

Filed under:
|
|
|

I need to have the ability to create user accounts on my Linux ( Fedora 10 ) and automatically assign a password via a bash script ( or otherwise, if need be ).

It's easy to create the user via Bash eg:
[whoever@server ]# /usr/sbin/useradd newuser

But is it possible to assign a password in Bash, something functionally similar to this (but automated):

[whoever@server ]# passwd newuser
Changing password for user testpass.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[whoever@server ]#

© Stack Overflow or respective owner

Related posts about linux

Related posts about bash