I have a script that downloads bank transactions to store in a database. To get these transactions requires a password for each account. The database is encrypted and requires a key to access it. All these keys and passwords are themselves encrypted and require a master key to retreive. The script prompts for the master key, uses this to retrieve all the necessary passwords and keys, and then does its work.
Right now this script is being called manually. Automating it to run periodically is easy, except for the part of securing the master key. Simply storing it in a file in plaintext does not seem very secure, as anybody who manages to get read access to the file now has wide open access to a lot of sensitive information. Storing it in a way that the script has it (for example obfuscating it in a binary called by the script) won't work either, because then anyone who can execute the script has an attack vector there.
I have read this question, the answer there appears to be "store it in a file" with added comments suggesting not in plain text. But even if the password is not plain text, it still seems like we have to communicate to the script how to read the file somehow, such as a decryption key or something, and we are back at square one.
gpg
you could use something likegpg-agent
.