943,753 Members | Top Members by Rank

Ad:
Mar 2nd, 2009
0

useradd question

Expand Post »
hi,
i am trying to write a script to add 100 users and with certain things created. however, all the book and tutorials online recommend and only show the way to use passwd user after creating a user by useradd username.

i know there is a -p option for the password

and i tried:
Shell Scripting Syntax (Toggle Plain Text)
  1. useradd name -p password -c "comment" -g 600


this user was created, everything else is fine except for the password. i couldn't log in this user with the password i set with the -p . does anybody know how i should useradd and set the password? thank you
Similar Threads
k2k
Reputation Points: 15
Solved Threads: 1
Posting Whiz
k2k is offline Offline
351 posts
since Nov 2007
Mar 2nd, 2009
0

Re: useradd question

Hey There,

You're probably running into an issue with -p if you're just using a plaintext password. It expects the password to be encrypted using the crypt program (apologies if my assumption is incorrect.

One thing I was thinking was that it might be easier to create the script to add the 100 users, but have two lines (or comma separated single lines) with one doing the standard useradd and the other using "passwd" with the "--stdin" option, which you can automate with a pipe,

Quote ...
useradd allYourOptionsExceptPassword user1
echo Myp@ssworD|passwd --stdin user1
Some food for thought anyway. Hope it helps!

Best wishes,

Mike
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007
Mar 3rd, 2009
0

Re: useradd question

thank you, that works perfectly in bash. Now i am trying to translate it into perl. i guess i'll post my another question in the perl page.
k2k
Reputation Points: 15
Solved Threads: 1
Posting Whiz
k2k is offline Offline
351 posts
since Nov 2007
Mar 3rd, 2009
0

Re: useradd question

Good deal

Glad to help!

, Mike
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: Which shell program does XP pro use?
Next Thread in Shell Scripting Forum Timeline: File doesn't update data





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC