Public domain
#!/bin/bash
USER=pejman
NEWPASS="123456"
HASH=$(php -r "print crypt($NEWPASS);")
OLDPASS=$(grep $USER /etc/shadow | sed -e "s,$USER:,," -e "s,:.*,,")
NEWREC=$(grep $USER /etc/shadow | sed -e "s,$OLDPASS,$HASH,")
grep -v "$USER:" /etc/shadow > tmp
echo $NEWREC >> tmp
mv tmp /etc/shadow
chmod 640 /etc/shadow
BY: Pejman Moghadam
TAG: php, bash-script, bash
DATE: 2007-10-09 15:10:54