In a good way that we did in the past to provide passwords for the necessary scenarios when using key-based authentication, it was impossible or necessary to use passwords for applications, services, mysql, regardless ... we saved the passwords in an encrypted file, and then decrypted this file at run time to provide a password for scripts.
Decrypting the password for the script, let it call yourcreds.rb, was limited only to root, and unencrypted passwords were not stored anywhere. For example, you can run:
root @host: ~ # yourcreds.rb | grep mysql | awk {'print $ 3'}
Which without awk, for example, prints a stored string: service | user | password | description | etc ... mysql mysqluser password ....
With yourcreds.rb (or whatever), you can only display the password and easily include this method in scripts / cron jobs in larger or more complex environments.
Also, if I remember correctly, we did not have to use grep / awk or anything else. We just programmed in the parse options, for example: yourcreds.rb list mysql or yourcreds.rb -l, etc.
We used blowfish and yamls to store encrypted passwords. I am sure you can be creative. Just make sure it's a bullet of evidence for everyone but root.
source share