Ask HN: What do you do about API keys?

1 points by stickynotememo ↗ HN
Having them in plaintext always seemed like a bad idea. Forget agents accidentally reading .env; any random package you get from the AUR can trivially read all your keys.

Ideally you'd have read permissions restricted to users/groups that need it, but since most software that needs it is under the user UID, I don't see how this would work.

8 comments

[ 0.21 ms ] story [ 3.2 ms ] thread
This is why I won't use models from/and hosted by China.

American models get nuts when you paste a key in the chat and tell you to rotate it as soon as possible. They'll often update agents.md and describe the key is in ...env file and how to load it for a script. It avoids putting the key in AI's request like the plague.

I often wonder if Chinese models instead just gulp it down and hunt for more. Anyone know?

- Don't put them in non-trivial paths so they are not easy targets. I never put them under a path that `git clean -xdf` erases, for example.

- One thing that always scares me is that some third party code will just do a getenv AWS_ACCESS_KEY_ID in whatever language and send it out somewhere. So I tend to either invent non trivial environment variables names, and/or do unsetenv when the process starts, after it loads them to some internal config struct.