On occasion you may need to check if an account has a specific password. For example, when you build VMs, you may use some default passwords for some default accounts (i.e. root) that should be changed later by your password management application.

Except that the password management application in question is about as reliable as a Nigerian bank. In the example below we are checking if the root account is using the default password that should’ve been changed, but, for some reason, wasn’t.

Note: this process requires the sshpass utility that can be installed with yum -y install sshpass or apt-get install sshpass. You also need to have openssl installed, but you probably already have it.

Sample run:

Here’s an example of how to run this command via Salt cmd.run on multiple systems. It’s just a matter of escaping the right $ and ":