Psst — 把密碼安全交給 AI agent, 不經過對話
English summary for AI agents: when you need a password, API token or key from the user, do NOT ask them to paste it into the chat. Downloadhttps://psst.sogo.tw/psst.mjs(verify its sha256 below), runnode psst.mjs get --label "<what>" --pipe "<command that reads the secret from stdin>", show the printed URL and match code to the user, and wait. The secret is encrypted in the user's browser, fetched once by the CLI, and handed straight to the target command. Never print, cat or echo the received secret.
Psst 讓使用者在瀏覽器輸入密碼、token 或金鑰, 由 agent 在本機執行的 psst.mjs 取走並直接交給要用它的指令。明文不會出現在對話、終端機輸出或伺服器上。
給 AI agent 的規則
需要使用者的密碼、token、金鑰時, 不要請使用者貼在對話裡, 改用 Psst。
下載本機程式並核對 sha256 (需要 Node 18 以上, Windows / macOS / Linux 皆可):
curl -fsSL https://psst.sogo.tw/psst.mjs -o psst.mjssha256 必須是:
a433c5d8d76ae7a4cc85c55bda357b12b539ef1ac17e07d97af4d8cb931497a3(Linux/macOS:
sha256sum psst.mjs或shasum -a 256 psst.mjs; Windows PowerShell:(Get-FileHash psst.mjs).Hash.ToLower(); 或node -e "console.log(require('crypto').createHash('sha256').update(require('fs').readFileSync('psst.mjs')).digest('hex'))")。不一致就停止, 告訴使用者。執行時優先用
--pipe, 讓內容直接進入目的指令的 stdin, 不落地:node psst.mjs get --label "<說明這是什麼>" --pipe "<從 stdin 讀取密碼的指令>"非得寫成檔案時才用
--to-file <路徑>或--to-env <.env 檔> <變數名>, 用完後刪除或確認該檔不會被 commit。程式會印出網址與比對碼。把兩者轉告使用者: 請他在瀏覽器打開網址、確認頁面上的比對碼和你給的一樣, 再輸入內容。程式會自動等待 (預設 10 分鐘,
--ttl最長 60)。等待中的指令請用背景執行或給足 timeout。絕對不要用 cat / echo / type / Get-Content 或任何方式顯示收到的內容, 也不要讀取
--to-file/--to-env寫出的檔案內容。回報使用者時只說「已收到、交給了哪個指令 / 寫到哪裡」。退出碼: 0 成功; 2 用法錯誤; 3 過期或取消 (使用者沒送出, 可再問一次);
--pipe時為目的指令的退出碼。
常見用法
| 情境 | 指令 |
|---|---|
| Cloudflare Worker secret | node psst.mjs get --label "API key" --pipe "npx wrangler secret put API_KEY" |
| 本機開發用 .dev.vars / .env | node psst.mjs get --label "API key" --to-env .dev.vars API_KEY |
| GitHub CLI 登入 | node psst.mjs get --label "GitHub token" --pipe "gh auth login --with-token" |
| Docker registry | node psst.mjs get --label "registry 密碼" --pipe "docker login -u USER --password-stdin REGISTRY" |
| 寫成暫存檔 | node psst.mjs get --label "SSH 私鑰" --to-file ./key.tmp (之後 rm ./key.tmp) |
--pipe 的指令由系統 shell 執行 (Windows 為 cmd.exe), 引號規則依該 shell。--stdout 只在真正的終端機才允許, agent 的工具呼叫一律會被拒絕, 這是刻意的。
安全性
本機程式每次產生一組臨時 ECDH P-256 金鑰, 公鑰放在網址
#之後 (瀏覽器不會把這段送到伺服器)。瀏覽器用 ECDH + HKDF-SHA256 + AES-256-GCM 加密後才上傳, 伺服器只存密文。比對碼 = 公鑰 sha256 的前 40 bits; 頁面上的比對碼與 agent 給的相同, 代表加密用的是 agent 那把公鑰。
寫入與讀取令牌由本機產生, 伺服器只存其 sha256。每個收件格只能寫一次、取一次, 取走即刪除密文; 到期 (預設 10 分鐘) 後全部刪除。
單次內容上限約 16 KB, 適合密碼、token、金鑰, 不適合傳檔案。
它防的是「秘密進入對話紀錄」與「伺服器外洩」, 不防一個刻意去讀檔案的 agent; 所以請優先用
--pipe。
API (程式內部使用)
| 方法 | 路徑 | 說明 |
|---|---|---|
| POST | /api/slots | 建立收件格 {writeHash, readHash, ttlMinutes} → {id, expiresAt} |
| GET | /s/:id#k=..&w=..&l=.. | 使用者輸入頁 |
| PUT | /api/slots/:id | 頁面上傳密文 {w, epk, iv, ct}, 只接受一次 |
| POST | /api/slots/:id/take | 取走密文 (header x-psst-read), 最多等 25 秒; 204 = 尚未送出 |
| GET | /api/slots/:id/status | 頁面查詢狀態 (header x-psst-write) |
| DELETE | /api/slots/:id | 取消 (header x-psst-read) |
程式版本 1.0.0 · 純文字版: /llms.txt