身為 leo,我要 git push 不再把 token 印出來,我才不用每次都判斷要不要輪替金鑰 #47

Open
opened 2026-08-20 15:19:04 +00:00 by claude-code · 0 comments
Member

現象

每一次 git push 到 Gitea,git 都會印這一行:

$ git config lfs.https://claude-code:<token 真身>@git.uncle6.me/….git/info/lfs.locksverify true

token 明文出現在輸出裡 ⇒ 進 transcript、進 log、進任何貼出去的畫面。2026-08-20 一天發生數次。

根因

remote URL 裡嵌著 token(https://claude-code:<token>@git.uncle6.me/…)。只要它在,任何印出 remote URL 的訊息都會洩一次。

為什麼今晚沒直接修

實測過乾淨網址可行(macOS keychain 供認證,來源 /Library/Developer/CommandLineTools/usr/share/git-core/gitconfig),但六個地方靠 remote URL 抽 token

  • InkStoneCosystem-dev/scripts/dispatch-agent.sh.claude/hooks/factory-idle-guard.shscripts/wiki-panorama.sh
  • ISEPhooks/factory-idle-guard.shscripts/gitea-labels-sync.shscripts/wiki-panorama.sh

拿掉 token 後這六個會靜默拿到空字串 → 401,而依 2026-08-13 的教訓那會被讀成「找不到/不存在」。半夜動一支 hook 風險不對稱,所以還原了。

這是記錄下來的假設,不是提問:修法應該是把 token 來源統一到 .envGITEA_TOKEN_CLAUDE_CODEcredentials-map.md 已收錄),六處改成同一支共用 lookup,然後 remote URL 才能改乾淨。

驗收

  • 六處都不再從 remote URL 抽 token,改讀 .env
  • 兩個 repo 的 remote URL 不含憑證
  • git push 的輸出裡沒有任何 token 字樣
  • 六處各自實跑一次證明仍能認證(不是只看程式碼改了)

順帶

claude-code 這把 token 今天已在 transcript 裡明文出現多次,要不要輪替是 leo 的決定。

## 現象 每一次 `git push` 到 Gitea,git 都會印這一行: ``` $ git config lfs.https://claude-code:<token 真身>@git.uncle6.me/….git/info/lfs.locksverify true ``` **token 明文出現在輸出裡** ⇒ 進 transcript、進 log、進任何貼出去的畫面。2026-08-20 一天發生數次。 ## 根因 remote URL 裡嵌著 token(`https://claude-code:<token>@git.uncle6.me/…`)。只要它在,任何印出 remote URL 的訊息都會洩一次。 ## 為什麼今晚沒直接修 實測過乾淨網址可行(macOS keychain 供認證,來源 `/Library/Developer/CommandLineTools/usr/share/git-core/gitconfig`),但**六個地方靠 remote URL 抽 token**: - `InkStoneCo`:`system-dev/scripts/dispatch-agent.sh`、`.claude/hooks/factory-idle-guard.sh`、`scripts/wiki-panorama.sh` - `ISEP`:`hooks/factory-idle-guard.sh`、`scripts/gitea-labels-sync.sh`、`scripts/wiki-panorama.sh` 拿掉 token 後這六個會**靜默拿到空字串 → 401**,而依 2026-08-13 的教訓那會被讀成「找不到/不存在」。半夜動一支 hook 風險不對稱,所以還原了。 **這是記錄下來的假設,不是提問**:修法應該是把 token 來源統一到 `.env`(`GITEA_TOKEN_CLAUDE_CODE`,`credentials-map.md` 已收錄),六處改成同一支共用 lookup,然後 remote URL 才能改乾淨。 ## 驗收 - 六處都不再從 remote URL 抽 token,改讀 `.env` - 兩個 repo 的 remote URL 不含憑證 - `git push` 的輸出裡沒有任何 token 字樣 - 六處各自實跑一次證明仍能認證(不是只看程式碼改了) ## 順帶 `claude-code` 這把 token 今天已在 transcript 裡明文出現多次,要不要輪替是 leo 的決定。
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: inkstone/ISEP#47