Password Reset Remote SSH
The “Password Reset Remote SSH” script uses different methods for root (id=0) account (passwd that asks for only new password) and other accounts (passwd that asks for existing password and then for new passwords).
This script also uses a shadow account when specified to run password reset using the passwd USER command.
The script “Password Reset Remote Root” can only reset the password for the root account without any shadow records.
However, this script could be used as an example to develop custom password reset scripts for specific scenarios not covered by “Password Reset Remote SSH” script.
The “Password Reset Remote SSH” script executed for the record without shadow record:
if [ "`id -u`" -eq 0 ]; then
passwd <<EOF\n{{NEWPWD}}\n{{NEWPWD}}\nEOF
echo xtam passwd error code: $?
else
passwd <<EOF\n{{OLDPWD}}\n{{NEWPWD}}\n{{NEWPWD}}\nEOF
echo xtam passwd error code: $?
fi
The “Password Reset Remote SSH” script executed for the record with shadow record:
sudo -S passwd {{LOGIN}} <<EOF\n{{NEWPWD}}\n{{NEWPWD}}\nEOF
echo xtam passwd error code: $?