Secret Management
API keys and tokens belong in the environment variable file only. The configuration file (settings.json) is plain text, so if the file leaks, the keys are exposed as-is.
This principle applies from the 2026.07 release onward; existing installations continue to work unchanged (see "Migrating Existing Installations" below).
/etc/kopens/plantpulse-studio.envThe path of the environment variable file is /etc/kopens/plantpulse-studio.env. It sits outside the repo tree, not inside the installation directory (/opt/kopens/plantpulse-studio-docker), and its permissions are 0600. All three products — platform · ai · studio — use /etc/kopens/plantpulse-<product>.env under the same convention.
The .env at the root of the installation directory is the old path. Nothing reads it now, so editing it changes nothing in the stack. If the old file is still around, it is only good for cross-checking after migration.
The Six Secrets — What and When
These are the values you put in .env. Leave the keys for features you don't use empty.
| Environment Variable | Purpose | When It's Needed | If Missing |
|---|---|---|---|
PLATFORM_API_KEY | PlantPulse platform service key | All live data queries (sites, equipment, tags, alarms) | Live data cannot be queried from chat queries or deployed apps |
ANTHROPIC_API_KEY | Anthropic key | When the AI provider is anthropic | The agent does not actually run (stub responses) |
OPENAI_API_KEY | OpenAI key | When the AI provider is openai | Same as above |
AI_API_KEY | OpenAI-compatible gateway key | When using an in-house AI gateway | Same as above |
GIT_TOKEN | Remote Git access token (PAT) | When pushing app source to the customer's GitLab/GitHub | Only the Git push feature is unavailable |
APP_REGISTRY_TOKEN | App image registry token | When pushing a deployed app as a Docker image | Only the image push feature is unavailable |
You only need the single key matching the provider selected under Settings → AI tab.
For sites using an in-house gateway (OpenAI-compatible), that is AI_API_KEY.
Entering Keys
sudo vi /etc/kopens/plantpulse-studio.env
# ── 비밀(키·토큰) — 환경변수 전용 ─────────────────────────
PLATFORM_API_KEY=...
ANTHROPIC_API_KEY=sk-ant-...
# OPENAI_API_KEY=
# AI_API_KEY=
# GIT_TOKEN=
# APP_REGISTRY_TOKEN=
sudo chmod 600 /etc/kopens/plantpulse-studio.env
cd /opt/kopens/plantpulse-studio-docker && bash bin/restart.sh
docker restart will not change the keysdocker restart pp-studio-server does not re-read .env. It simply restarts carrying the old environment variables that were injected when the container was created. This is the classic trap where you change a key and then spend a long time wondering "why is it still the same?"
You must recreate the container.
bash bin/restart.sh
# 또는
docker compose up -d --force-recreate
.env does not mean it reaches the containerOnly the variables listed in the environment: section of docker-compose.yml are passed to the container.
The six above are already wired up, but if you add a new variable that isn't in the table, you must add it to compose as well. (There are real cases where AI came up disabled because of a missed pass-through.)
Verifying It Took Effect
# 서버가 인식한 키 출처 확인 — 부팅 로그
docker logs pp-studio-server 2>&1 | head -40
On screen, it's working correctly when the key input fields under the Settings → AI / Platform tabs are disabled and show "Managed by environment variable".
Precedence and Migrating Existing Installations
| Rank | Source | Notes |
|---|---|---|
| 1 | Environment variable (/etc/kopens/plantpulse-studio.env) | If a value is present, this always wins |
| 2 | settings.json | Legacy fallback — for compatibility with older installations |
Upgrading will not suddenly break an existing installation. However, if secrets remain in the file, the boot log tells you what needs to move (values never appear in the log — only which item should move to which environment variable).
settings.json 에 비밀이 남아 있습니다 — … platform.apiKey → PLATFORM_API_KEY
Migration is a three-step procedure.
- Move the value to the corresponding environment variable in
/etc/kopens/plantpulse-studio.env bash bin/restart.sh- Confirm on the Settings screen that the item now reads "Managed by environment variable", then delete the old value from
settings.json→ the boot warning disappears
<DATA_ROOT>/state/settings.json (default /var/lib/pp-studio/state/settings.json).
Back it up before editing, and restart after editing.
Key Rotation
ANTHROPIC_API_KEY · AI_API_KEY have dedicated tooling. It updates the file and recreates the container in one step, and the value is not left in shell history.
cd /opt/kopens/plantpulse-studio-docker
bash bin/backup.sh # ① 되돌릴 지점 확보
bin/passwd.sh ANTHROPIC_API_KEY # ② 값 생략 → 프롬프트로 입력
bash bin/status.sh # ③ 헬스 확인
Detailed usage is in Changing Passwords · API Keys.
The remaining keys (PLATFORM_API_KEY · OPENAI_API_KEY · GIT_TOKEN · APP_REGISTRY_TOKEN) are not covered by the tool; edit the file directly.
cd /opt/kopens/plantpulse-studio-docker
bash bin/backup.sh # ① 되돌릴 지점 확보
sudo vi /etc/kopens/plantpulse-studio.env # ② 새 키로 교체
bash bin/restart.sh # ③ 컨테이너 재생성
bash bin/status.sh # ④ 헬스 확인
After rotation, the sure way to check real behavior is one chat query (verifies the platform key) and one app build (verifies the AI key).
Protections Applied Automatically
| Item | Behavior |
|---|---|
| File permissions | On every server boot, settings.json · the environment variable file are forced to 0600 and the state directory to 0700 |
| Audit log | Settings changes record the fields that changed — for secrets, only a fingerprint (first 8 characters of the hash) instead of the value |
| UI | Keys managed by environment variables have input disabled, so they cannot be overwritten by mistake |
| Key proxying | The platform key stays inside the server and is attached only to requests from logged-in users (never to anonymous requests) |
Exception — MCP External Server Tokens
Tokens for external MCP servers, which users add in any number under Settings → MCP tab, cannot be expressed as environment variables because their count varies, so they are stored in settings.json.
(These are less sensitive than the platform and AI keys.)
Rules to Follow
- Do not commit the environment variable file or
settings.jsonto version control (Git). This is exactly why the source of truth lives outside the repo tree (/etc/kopens/). - Do not paste keys into chat, email, or ticket bodies.
- Do not share backup archives without authorization — see the handling cautions in Backup and Restore.
Revoke first at the issuer (platform · AI provider · Git · registry), issue a new key, then perform the "Key Rotation" procedure above. The old key remains in memory until the server is restarted.
Related Documents
- Changing Passwords · API Keys — how to use
bin/passwd.sh - Installation — the full list of environment variables
- Settings (Administrator) — what you can check on screen
- Troubleshooting