Script to create user
Good morning everybody,
I'm trying to create a script to create and configure users, so far, i can create, but i'm having one problems: 1) about the password, i discovered that when you pass it in useradd is the encrypted password. So what i want is to use passwd in my script, how i can put to be automatic? Thanks! Carlos |
Quote:
http://bash.cyberciti.biz/security/e...-login-script/ generics array |
Sorry but I didn't understand the script...
|
Expect is a program that "talks" to other interactive programs according to a script. Following the script, Expect knows what can be expected from a program and what the correct response should be. An interpreted language provides branching and high-level control structures to direct the dialogue. In addition, the user can take control and interact directly when desired, afterward returning control to the script.
http://linux.die.net/man/1/expect Samples http://www.aixmind.com/?p=1979 |
You might find it easier to use http://linux.die.net/man/8/newusers
|
An easy way to do this in a script is to echo something into the passwd command. If you do, you'll need to add the --stdin option for passwd. Depending on the password that you set, you may want to force your new users to change their passwords the first time they log in. This can be accomplished with chage -d0. Here's a simple bash for loop that demonstrates this. It will add four users, set their passwords to be the same thing as their usernames, and force them to change their password the first time they log in.
for NAME in mike brian chris susan; do useradd $NAME; echo $NAME | passwd --stdin $NAME; chage -d0 $NAME; done Mike |
All times are GMT -5. The time now is 06:58 PM. |