﻿---
title: "把 auth.json 当密码"
summary: "~/.codex/auth.json 是文件凭据缓存。备份、同步盘、dotfiles 仓库都不要带上它。"
category: security
level: starter
surfaces: [cli]
tags: ["auth.json", "密钥", "dotfiles"]
canonical: /tips/auth-json-is-a-password/
---

# 把 auth.json 当密码

~/.codex/auth.json 是文件凭据缓存。备份、同步盘、dotfiles 仓库都不要带上它。

同类敏感物：

- `CODEX_API_KEY` / `OPENAI_API_KEY`
- `CODEX_ACCESS_TOKEN`
- MCP OAuth 令牌
- 会话记录（可能含密钥）

实践：

- `cli_auth_credentials_store = "keyring"`（支持的平台）
- 不要在 shell profile 里全局 export API key
- 定期轮换 access token
- 卸载 CLI **不会** 删除 `~/.codex/`。真要干净卸载，得自己删——那也会丢掉配置和历史

## 来源

- [Codex CLI Cheat Sheet](https://www.agenticcodingweekly.com/p/codex-cli-cheat-sheet)
