SUMMARY: How to create password in the script?

From: Stephanie C <stepchung_at_gmail.com>
Date: Wed May 07 2008 - 13:16:26 EDT
Thank you very much for all the responses. Here are couple options:

- Use 'expect'. I have to learn this.
- Use the following syntax within the script right after the 'useradd' line
to add the password into /etc/shadow file:
 echo ${useracct}:`perl -e '$x=crypt('password','n${useracct}'); print
$x'`:13798:::::: >> /etc/shadow
This works fine, but the shadow file has two lines for one user. One line is
the locked password and another has the added password line. I have to edit
the shadow file to remove the locked password line. This is no can do.
- Put a following line in the script  right after the useradd line:
passwd -u ${useracct} (this to unlock the account with a null password,
users need to set the password at first login). I will go with this option
for now.

Thanks.

Stephanie

QUESTION:
I have to create hundreds and hundreds (thousands) of user accounts on our
solaris 10 servers. I have created a script to do so. The problem is, I
don't want to set the password for these users by typing 'passwd' command
for every one of them (take forever to do this). I know Linux's useradd
command has an option '-p' to set the password, but not solaris. Is there a
way to create a default password in the script when create user account?

Here is my the useradd script:

#!/usr/bin/ksh

# 05/14/2006

# Author:

# Script: user_add.sh

#

DIRECT="/export/home/its"

GROUP="staff"

while read useracct

do

  useradd -d ${DIRECT}/${useracct} -g ${GROUP} -s /bin/ksh -m -k /etc/skel/
${useracct}

 * passwd ${useracct} < /dmp/userpassfile.txt (NOT WORKING, IT PROMPTS FOR
PASSWORD)*

done < /dmp/useraccount.txt
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Wed May 7 13:17:18 2008

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:44:11 EST