credentials
它能做什么
让 smolvm 虚拟机中的程序在你指定的网址上使用你的 API 密钥,但它永远无法读取该密钥。它适合智能体或不受信任的代码必须调用付费服务的人。
适用场景
- ✓当虚拟机中的智能体需要用你的密钥调用 API 时。
- ✓当你需要了解如何让密钥不进入虚拟机时。
- ✓当你想要证明密钥从未进入虚拟机的证据时。
技能链接
https://github.com/smol-machines/smolvm/blob/main/docs/credentials/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请让我的智能体用我的密钥调用我们的支付 API,但确保密钥绝不会被复制进虚拟机。”
每周 5 个新技能,1 分钟读完。
工作原理
虚拟机保存的是占位符,而不是真实密钥。宿主机在请求发出时才替换为真实值,并且只针对你指定的主机。该技能还会检查该值从未进入虚拟机。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
A credential the machine can use and never hold
Verified on smolvm v1.29.0 on macOS arm64, 2026-10-15, and on v1.18.2 on Linux aarch64, 2026-09-24, for everything that
is decided on the host; on v1.29.0 on macOS arm64 the substituted value also arrived at a real API
that echoes the headers it received, a dummy value. Done means the guest's variable is a placeholder, the value
is nowhere in the guest, the machine's record or smolvm's database, TLS to the bound host goes
through the machine's own CA, and a placeholder anywhere but a request header is refused before it
leaves the host (from v1.27.0 a binding with :body also substitutes into a form body).
The Linux runs used the scripts of their date; this version's preflight and cleanup scripts ran
on Linux aarch64 on v1.22.2 on 2026-10-03.
docs/credential-substitution.md in the smolvm repository is how the feature works: bindings,
where the value comes from, what the guest sees, what happens to each request, and the limits.
README.md has what was measured beside it. This file is how to set it up and prove it.
Procedure
- [ ] 1. preflight.sh the flag, the network backend, the host variable
- [ ] 2. create-credentialed.sh a machine bound to one host
- [ ] 3. verify-containment.sh the value stays out; the interceptor is on the path
- [ ] 4. your own request the first call that sends the value
- [ ] 5. cleanup.sh
1. Preflight. Read-only, and it never prints the value or its length.
export API_TOKEN=... # however your secrets manager hands it over
scripts/preflight.sh --var API_TOKEN --host api.example.com
Every script here reads the value from its own environment, so keep it exported in the shell that
runs create-credentialed.sh and verify-containment.sh as well as this one.
has_credential_flag=yes
default_backend=virtio-net
tsi_stream_intercept=yes
host_var_set=yes
host_form=ok
memory_required_mib=1024
result=ready
tsi_stream_intercept is read from the symbols of the bundled libkrun: a binding selects virtio-net
by default, and --net-backend tsi carries a credential only when libkrun exports
krun_set_stream_intercept, which both v1.18.2 release libraries do. host_form=rejected means the
host is neither a lowercase DNS name nor, from v1.26.0, a wildcard such as *.example.com; create
would refuse it anyway, with a clearer message.
2. Create the machine. The value is read from the environment of this command's machine start, and that is the value the machine uses until its next start.
scripts/create-credentialed.sh --var API_TOKEN --host api.example.com
workload_ready_after_s=1
guest_sees=placeholder
binding=api-token host=api.example.com
result=up
The command it runs is smolvm machine create ... --credential api-token=API_TOKEN@api.example.com
and then machine start. --credential implies --net. In a Smolfile the same binding is a
[[network.credentials]] table, in docs/credential-substitution.md.
3. Prove the value stayed out. Nothing this sends carries the placeholder where it would be
substituted, so the value goes nowhere during the check. On an Alpine guest it adds openssl and
curl with apk, which step 4 then uses. Run it on the machine create-credentialed.sh made, before
any workload of yours runs in it: the guest search hands the value to a grep in the guest for the
length of the search, so a workload that can replace grep could read it.
scripts/verify-containment.sh --var API_TOKEN --host api.example.com --other-host example.org
guest_variable=ok (placeholder)
value_in_guest=ok (0)
value_in_record=ok (0)
interception=ok (on)
passthrough=ok (real)
query_refused=ok (403)
refusal_text=smolvm credentials: placeholders are substituted in request headers only
result=contained
value_in_guest hands the value to a grep inside the guest on standard input for the length of
the search, and looks in every process environment and the writable trees inside the guest;
value_in_record searches the machine's directory and smolvm's database on the host;
interception reads the issuer of the bound host's certificate as the guest sees it, which is
smolvm <machine> credential CA, while --other-host keeps its real issuer.
4. Use it. The workload sends the placeholder in a header, exactly where the real key would go.
smolskill-cred is the machine create-credentialed.sh makes unless you
常见问题
密钥可以用于哪些网站?
只能用于你在设置时指定的 HTTPS 主机。
我如何知道密钥不在虚拟机内?
该技能包括一项检查,会在虚拟机、其设置以及 smolvm 数据库中搜索该值。
它在哪些电脑上经过了检验?
该技能列出了它测试过的 macOS 和 Linux 机器及其版本。
详情
作者的原始描述
Gives a workload in a smolvm machine an API key or token it can use but never read, by binding the credential to named HTTPS hosts so the guest holds only a placeholder and the host substitutes the value on the way out, then proves on the host that the value never entered the machine. Use when an agent or untrusted code inside a machine has to call an API with your key; when deciding between a credential binding and --secret-env; when a request from a credentialed machine comes back 403 or 502 from smolvm itself; or when you need evidence that a key stayed out of a machine. Do not use it for a
repo: smol-machines/smolvm
热度
- GitHub 星标
- 6.9k
- 排名
- #13716
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
branch-and-checkpoint
6.9k帮你的智能体将正在运行的 smolvm 虚拟机保存为检查点,之后恢复,暂停并继续运行,或分支为多个副本。
coding-agent
6.9k帮你的智能体在安全的 smolvm 虚拟机中运行 Claude Code 等编程智能体,并挂载你的项目文件夹。
dev-env
6.9k教你的智能体保持一个已安装工具的 smolvm 开发虚拟机,使其能快速重启,并在会话之间保留软件包。
docker-in-machine
6.9k帮你的智能体在 smolvm 虚拟机内运行 Docker 守护进程,使测试、构建以及需要启动容器的智能体能够在其中工作。