Where do the credentials your scripts need actually live on your servers?

Maxoq

Well-known member
Registered
Joined
Feb 25, 2015
Messages
549
Points
28
Every box I run ends up with a handful of scripts needing a database password or an API token, and I have never been happy with where those end up. Config file inside the project, env file next to it, a file in root's home read by cron. All of them work, and all of them have a way of ending up somewhere I did not intend.

The one that caught me was backups. A config file with live database credentials sat outside the document root but inside the folder the backup job archived, and that archive went to object storage with wider access than the server itself had. Nothing was breached as far as I can tell, but those credentials had been sitting somewhere less protected than the machine they belonged to for months, and I only noticed while looking for something else.

Since then anything holding a secret lives outside the tree that gets archived, and the backup job excludes it by name rather than by pattern, because a pattern is one typo away from including it again. Mode 600, owned by the user that runs the job, and never edited on the live box.

What I have not solved is rotation. Changing a database password means finding every place it was copied to, and I only reliably know about the copies I made myself. Does anyone here actually rotate credentials on a small fleet on a schedule, or is it something that only happens after something has already gone wrong?
 

Paul Wellner Bou

Well-known member
Registered
Joined
Apr 20, 2016
Messages
107
Points
16
Rotation only happens here after something goes wrong, and I stopped pretending otherwise. What I did instead was make the copies findable, because that was the actual blocker. Every secret goes in one file per host under a fixed path, and anything that needs it reads that file rather than holding its own copy. Rotating then means editing one place and restarting what reads it, which is a job small enough that I sometimes do it.

The part that still catches me is things that cached the credential at install time rather than reading it per run. WordPress config files, a couple of backup agents, anything with a setup wizard. Those never appear in a grep for the password because they wrote it somewhere of their own choosing. Do you know of a decent way to find those short of searching the whole filesystem for the string?
 

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top