Managing production passwords isn’t a trivial task. I was trying to deploy a containerized app the other day that had a database deployed with it. During the deployment, I was trying to find an easy way to set a secure password. I didn’t want anyone to know the password because I wanted only the application to know it and no one else. Also, the container was setup in a way that the database cannot be accessed from the outside world.

So instead of hard-coding the password, after doing some research, I used the following command:

This might look like some gibberish but it uses linux’s /dev/urandom to generate some randomness and extracts human readable characters like alphabets, numbers and common symbols like underscores, hyphens, pluses and equals.

Try it! it works!

Now, using clever bash interpolation syntax you can embed this password throughout your script in a secure way.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.