ciphermethod.com

20100421: changelin.sh

by on Apr.21, 2010, under Linux, Scripts

#!/bin/sh
# 20100421 – Created by Jamey Hopkins
echo
echo “Change Users Linux/AIX Password”
echo

if [ “$1” = “” ]
then
echo need server list
echo example: $0 servers.txt
echo
exit
fi

if [ ! -f $1 ]
then
echo “Server list $1 not found.”
echo
exit
fi

echo -n “Enter Users Login: ”
read LOGIN

echo “Enter new password”
echo -n “Password: ”
stty -echo
read PASS1
stty echo
echo
echo “Enter password again”
echo -n “Password: ”
stty -echo
read PASS2
stty echo

echo

if [ “$PASS1” != “$PASS2” ]
then
echo passwords did not match
exit
fi

LIST=$1

echo “$LOGIN:$PASS1” >account.info

for X in `cat $LIST`
do
echo Performing Password Change for $LOGIN on $X
scp ./account.info $X: >/dev/null
ssh $X “cat account.info | sudo /usr/sbin/chpasswd” >/dev/null
ssh $X rm account.info
done

rm account.info

No comments for this entry yet...

Leave a Reply

You must be logged in to post a comment.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

But Wait, There's More!

A few highly recommended friends...