Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
From: "Chuck" <nospam-chuck@harkness.cc>
Subject: Re: add +200 users and set the password automatically
Date: Wed, 02 May 2001 12:58:53 GMT	[thread overview]
Message-ID: <hwTH6.143879$fs3.22920623@typhoon.tampabay.rr.com> (raw)
In-Reply-To: 3AEB00D4.732082AE@coserv.net

In a similar situation I used the following script to set
initial passwords to "loginname-numericuserid".  Could be
modified to create random passwords instead.   Hope this
helps.

Needs to be called for each user name as in something like:
for u in `cat names.lst`
do
    setinitialpw $u
done

--- setinitialpw script below -- Must be run as root of
course

PRG=`basename $0`
usedefaultpw=y
if [ $# -lt 1 ]; then
        echo "Need a user name argument.\nAbort"
        exit 1
fi

## Subroutine
setdefaultpw(){
        pw=${user}-${uid}
        /usr/sbin/usermod -p $user <<EOF
$pw
$pw
EOF

        if [ $? ]; then
                echo "Set Password $pw for $user $comment"
                return 0
        else
                echo "Could not set password $pw for $user
$comment"
                return 1
        fi
}

user=$1
pwline=`grep "^$user:" /etc/passwd`
if [ -z "$pwline" ]; then
        print "$PRG ERROR: Could get info from /etc/passwd
for user [$user].\Abort"
        exit 2
fi
uid=`echo "$pwline" | cut -d : -f 3`
comment=`echo "$pwline" | cut -d : -f 5`
if [ -z "$uid" ]; then
        print "$PRG ERROR: Could not extract UID for user
[$user].\Abort"
        exit 3
fi
if [ "$usedefaultpw" != "y" ]; then
        echo "Other than default pw not implemented
yet.\nAbort"
        exit 4
else
        setdefaultpw
        rval=$?
        if [ $rval -ne 0 ]; then
                exit 5
        fi
fi
exit 0




"system PRIVILEGED account" <plindsey@coserv.net> wrote in
message news:3AEB00D4.732082AE@coserv.net...
> Norbert Gnipp wrote:
>
> > Hi there,
> >
> > We are planning to add up to 200 users on out Tru64
V5.0a Server.
> > To add an user account is not a problem, but to set up
the password.
> >
> > So we are looking for help to set the password
automatically.
> >
> > Normally the unix password program want a user action to
set the
> > password, but in our case we want that we can use the
password
> > program with a parameter or a variable to set the
password without
> > an user action.
> >
> > Regards
> > N. Gnipp
>
> you could set the password to be random then use a script
running from
> root to passwd each account *or*
> you could just set the password field to :: in the
etc/passwd and expire
> those accounts so they would have to change after first
login
>
>




      reply	other threads:[~2001-05-02 12:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-04  5:00 add +200 users and set the password automatically Norbert Gnipp
2000-12-04  5:00 ` Adriano Prado
2001-04-28 17:41 ` system PRIVILEGED account
2001-05-02 12:58   ` Chuck [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox