Re: SUMMARY: How to create password in the script?

From: Stephanie C <stepchung_at_gmail.com>
Date: Wed May 07 2008 - 14:11:29 EDT
I forgot one more option:
- Add the line: passwd -u ${useracct} right after the line 'useradd' to
unlock password and set the password to null. Users need to set the password
at first login. I select this option for now. Thanks.

Stepahnie

On Wed, May 7, 2008 at 10:40 AM, Stephanie C <stepchung@gmail.com> wrote:

> 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.
>
> 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 15:51:10 2008

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