← 返回
未分类

Pass凭据管理器

安全存储 API Key、数据库密码、授权码等敏感信息。使用 GPG 加密,本地存储,Git 备份加密后文件。替代硬编码密码,防止密钥泄露。触发词:密码管理、API Key 存储、密钥管理、凭据加密、password manager、secret management、pass、password-store。
user_cybest
未分类 community v1.0.0 2 版本 99122.8 Key: 无需
★ 0
Stars
📥 113
下载
💾 1
安装
2
版本
#latest

概述

Pass 凭据管理器

基于 pass 的标准 Unix 密码管理方案。

核心架构

~/.password-store/          # GPG 加密的密码库
├── .gpg-id                 # GPG 密钥 ID
├── .git/                   # Git 版本控制
├── llm/api-key.gpg         # LLM API Key
├── postgres/               # 数据库密码
├── qq-mail/                # 邮箱授权码
└── weixin/                 # 微信推送 ID

安全特性

  • GPG 对称加密(AES256)
  • Git 私有仓库备份
  • 本地存储,无云端依赖

常用命令

读取凭据

pass show <path>           # 显示完整内容
pass show -c <path>        # 复制到剪贴板 (45s 后清除)

存储凭据

pass insert <path>         # 交互式输入
pass insert -m <path>      # 多行内容 (如配置文件)
pass edit <path>           # 编辑器打开

管理

pass ls                    # 列出所有
pass find <keyword>        # 搜索
pass rm <path>             # 删除
pass mv <old> <new>        # 重命名/移动

标准路径命名

服务类型路径示例
--------------------
LLM APIllm/api-key
数据库postgres/-password
邮箱-mail/auth-code
推送服务/user-id
云服务/access-key

在脚本中使用

Bash

API_KEY=$(pass show llm/api-key)
DB_PASS=$(pass show postgres/stock_market-password)

Python

import subprocess

def get_credential(path: str) -> str:
    result = subprocess.run(
        ["pass", "show", path],
        capture_output=True, text=True
    )
    if result.returncode != 0:
        raise RuntimeError(f"Failed to get credential: {path}")
    return result.stdout.strip()

api_key = get_credential("llm/api-key")

初始化新环境

# 1. 安装 pass
apt install pass  # Debian/Ubuntu
brew install pass # macOS

# 2. 克隆密码库
git clone <私有仓库> ~/.password-store

# 3. 验证 GPG 密钥
gpg --list-keys

备份与恢复

备份到 Git

cd ~/.password-store
git add -A && git commit -m "Update credentials" && git push

自动备份

建议配置 cron 或 hook 在 pass insert/pass edit 后自动提交。

最佳实践

  1. 路径分类 - 按服务/用途分层组织
  2. 多行存储 - 复杂配置用 pass insert -m
  3. 定期同步 - git pull 获取最新变更
  4. 权限控制 - chmod 700 ~/.password-store
  5. 禁止硬编码 - 永远不要在代码中写入明文密码

禁止事项

  • ❌ 在聊天/日志/代码生成中粘贴真实密钥
  • ❌ 将密码库推送到公开仓库
  • ❌ 在 CI/CD 日志中打印 pass show 输出

版本历史

共 2 个版本

  • v1.0.1 更新描述
    2026-04-01 18:25 安全 安全
  • v1.0.0 Initial release 当前
    2026-04-01 15:25 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,217 📥 266,653
ai-intelligence

ontology

oswalpalash
类型化知识图谱,用于结构化智能体记忆与可组合技能。支持创建/查询实体(人员、项目、任务、事件、文档)及关联...
★ 714 📥 243,978
ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,362 📥 318,676