[小技巧] 如何在命令行中安全存取密钥信息:以 OpenAI API 密钥为例

date
May 21, 2023
slug
tip-macos-api-keychain-access
status
Published
summary
小技巧
tags
tip
type
Post
notion image

Problem & Summary

security add-generic-password -D "secure note" -s "OPENAI_API_KEY" -a "OPENAI_API_KEY" -w

security find-generic-password -s "OPENAI_API_KEY" -w

# in .zshrc

command -v security && export OPENAI_API_KEY=$(security find-generic-password -s "OPENAI_API_KEY" -w)

echo $OPENAI_API_KEY

Solution

    Screenshots

    notion image

    © Ying Bun 2021 - 2024