Script for change password

#Script for change password for any user

 

#!/bin/sh
r=`od -An -N2 -i /dev/random`
r1=`od -An -N2 -i /dev/random`
r2=`od -An -N2 -i /dev/random`
# od -An -N2 -i /dev/random this command pick a series of random number

i=root
# store user name in varable

fin=`echo $r|tr ’0-9′ ‘@#!^&%@’`
# tr command convert match parameter with given argument ( @#!^&%@ ) .

fin1=`echo $r1|tr ’0-9′ ‘[4,1,9][H-J]‘`
fin2=`echo $r2|tr ’0-9′ ‘p,R,s,&,~’`
echo $fin$fin1$fin2 >/root/log
# store converted value in single file.

echo $fin$fin1$fin2 | passwd “$i” –stdin
# this will change password of root user which is store in i variable.

echo; echo “User $username’s password changed!”

mail -s “Password Changed” mail@gmail.com < /root/log
# mail new password to given email address

Leave a Reply

Your email address will not be published. Required fields are marked *