Skill站外收录 @skilllib/skill-2117939930272414269
managing-secrets
提供加密密钥与敏感信息的全生命周期管理能力,支持按主机、用户或共享范围分类存储,通过自动化加解密流程实现安全分发,并具备密钥轮换、访问权限控制及故障排查功能,适用于多环境下的机密配置治理。
效率工具 AI 技能
Skills.MD
# Managing Secrets
## Overview
This project uses **sops-nix** with **age** keys for secret management. Secrets
are stored in `secrets/` and decrypted at runtime.
## Directory Structure
```
secrets/
├── <hostname>/ # Host-specific secrets
│ └── default.yaml # Host secrets file
├── <username>/ # User-specific secrets
│ └── default.yaml # User secrets file
└── shared/ # Shared/Global secrets
```
## Configuration (.sops.yaml)
Access rules are defined in `.sops.yaml` at the project root. Keys are defined
groups (e.g., `hosts`, `users`) and creation rules map files to key groups.
## Adding a New Secret Workflow
Copy this checklist and track your progress:
```
Secret Addition Progress:
- [ ] Step 1: Identify which file needs the secret (host/user/shared)
- [ ] Step 2: Edit the appropriate secrets file with sops
- [ ] Step 3: Add key-value pair to YAML
- [ ] Step 4: Reference in Nix module with sops.secrets
- [ ] Step 5: Verify secret path in target service
- [ ] Step 6: Test secret access after rebuild
```
### Step 1: Identify Secret Location
Decide based on scope:
- Host-specific (hostname, SSH keys) → `secrets/<hostname>/default.yaml`
- User-specific (tokens, passwords) → `secrets/<username>/default.yaml`
- Shared (API keys used everywhere) → `secrets/shared/`
### Step 2-3: Edit and Add Secret
```bash
sops secrets/<path>/default.yaml
```
Add your secret:
```yaml
my_secret_key: "super_secret_value"
```
### Step 4: Reference in Nix
```nix
sops.secrets."my_secret_key" = {
sopsFile = lib.getFile "secrets/<path>/default.yaml";
# Optional: specify owner, mode, etc.
};
```
### Step 5: Verify Path
System secrets: `/run/secrets/my_secret_key` Home-manager secrets:
`$XDG_RUNTIME_DIR/secrets/my_secret_key`
### Step 6: Test
After rebuild, verify the secret is accessible:
```bash
# System
sudo cat /run/secrets/my_secret_key
# Home
cat $XDG_RUNTIME_DIR/secrets/my_secret_key
```
## Additional Workflows
### Editing Secrets
To edit or view an encrypted file:
```bash
sops secrets/<path>/default.yaml
```
_Editor will open with decrypted content. Saves re-encrypt automatically._
### Rekeying (Rotating Keys)
If `.sops.yaml` rules change (e.g., adding a new host key):
```bash
# Update all secrets based on .sops.yaml rules
sops updatekeys secrets/**/*.yaml
```
## Common Issues
| Symptom | Likely Cause | Solution |
| ---------------------- | ----------------------------- | ------------------------------------------------------------ |
| "File not found" | Incorrect sopsFile path | Use `lib.getFile` or verify relative path |
| "Permission denied" | Key not in .sops.yaml | Add host/user key to appropriate group |
| "Failed to decrypt" | Wrong age key | Check `sops.age.keyFile` path is correct |
| "Secret not appearing" | Service started before secret | Add `systemd.services.<name>.after = [ "sops-nix.service" ]` |
## Debugging Tips
**"File not found"**:
- Ensure `sopsFile` path uses `lib.getFile` or relative path correctly.
**"Permission denied"**:
- Check that the host/user SSH key is in `.sops.yaml`.
- Verify the runtime key path matches `sops.age.keyFile` or
`sops.age.sshKeyPaths`.
**Service can't read secret**:
- Verify the service runs after sops-nix:
`systemd.services.<name>.after = [ "sops-nix.service" ]`
- Check file permissions on the secret path
## See Also
- **Configuration layers**: See [configuring-layers](../configuring-layers/) for
understanding where to place secret references
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「managing-secrets」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次