I know that simply encrypting and decrypting passwords in a script is as bad as storing them in plain text, but I've been searching for an answer to this for a few days now, and haven't found an answer that fits the problem I'm having.
Here's the scenario. I'll give more details than I think may be relevant, just in case...
I have a VMware Management Assistant machine running SuSE Enterprise 11, which in turn is talking to an APC UPS. When the UPS goes to battery power it is set to run a script that will gracefully shutdown the VMware virtual machines running on an ESXi cluster. In order to do this the script needs to be able to automatically login to the ESXi machines using a local (to the ESXi machines) username/password combo.
I've written the script to handle the shutdowns in Perl using VMware's API, but the username/password issue has me stumped. Prompting for a password won't work as I need it to run automatically (what happens if the power goes out and no one is around to enter the password?).
I'm at quite a loss as to how to handle this situation. I know I could hash the password using something like Authen::Passphrase::BlowfishCrypt, but how would I then pass it to the ESXi host for the login? Am I maybe approaching this whole thing from the wrong direction, or is there a solution that I'm just not seeing?
Thanks in advance for your help.