I'm developing an application which is distributed on a VM. The default password is always the same, but it's hash in /etc/shadow
changes with every release. How can I programmatically (e.g., from a bash
script) find out whether the password was changed? Checking the hash is not an option because if the password was changed to something else and back, it will be different. I also want to keep the check as simple as possible.
1 Answer
If you know the passwd, you can generate de md5 string with
openssl passwd -salt $salt -1 foo
The point is getting the value for "$salt". This can be retrieved using awk on the crypted passwd from /etc/shadow
.
echo $CRYPTIC | awk -F\$ '{print $3}'
chage -l <user>
should give you this information.