How can I save my secret keys and password securely in my version control system?

前端 未结 17 1745
生来不讨喜
生来不讨喜 2020-11-29 14:49

I keep important settings like the hostnames and ports of development and production servers in my version control system. But I know that it\'s bad practice to kee

17条回答
  •  自闭症患者
    2020-11-29 15:17

    This is what I do:

    • Keep all secrets as env vars in $HOME/.secrets (go-r perms) that $HOME/.bashrc sources (this way if you open .bashrc in front of someone, they won't see the secrets)
    • Configuration files are stored in VCS as templates, such as config.properties stored as config.properties.tmpl
    • The template files contain a placeholder for the secret, such as:

      my.password=##MY_PASSWORD##

    • On application deployment, script is ran that transforms the template file into the target file, replacing placeholders with values of environment variables, such as changing ##MY_PASSWORD## to the value of $MY_PASSWORD.

提交回复
热议问题