On Wed, 1 Jan 2003, Robert Rolfe wrote:
> "vserver blah exec passwd root <password>"??
There are probably better ways. I always used to use an expect script:
http://www.paul.sladen.org/junk/useful/reset-password.sh
[also attached]. Or just poke the hashed value you want into the
`/etc/passwd' file on the vserver.
-Paul
--
Nottingham, GB
#! /bin/bash
# and autopasswd that checks whether the user is in %customers before
# allowing the update
if [ -z "$2" ] ; then
echo Usage: $0 username passwd
exit 1
fi
USERNAME="$1"
PASSWD="$2"
id="/usr/bin/id"
grep="/bin/grep"
if ( $id -Gn $USERNAME | $grep customers ); then
(expect - $USERNAME $PASSWD || exit 3) <<'EOF-EXPECT'
# exp_internal 1
spawn "/usr/bin/passwd" [lindex $argv 0]
set passwd [lindex $argv 1]
set send_slow {8 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
set timeout -1
expect -exact "Enter new UNIX password: "
send -- "$passwd\r"
expect -exact "\r\nRetype new UNIX password: "
send -- "$passwd\r"
expect -re "^passwd\: password updated successfully$"
EOF-EXPECT
else
echo User is not in %customers
exit 2
fi;