If you need to script a password change you have two main options:
Option one is a bit of a mess and option two requires an encrypted version of the password. At first, we couldn’t figure out how to encrypt the password but then we realized that you could use the Perl crypt function.
An example of number two:
#!/bin/bash usermod -p `perl -e 'print crypt("test", "salt")'` root;
That’s all there is to it!