从零开始:15 分钟跑通第一条路由
本教程带你完成:安装 Airlock → 启动桌面端 → 创建并验证第一条 HTTP 路由 → 再创建 SSH 与 LLM 路由 → 最后轮换和撤销凭据。完成后你就掌握了日常使用 Airlock 的完整闭环。
01
前置条件
macOS 12+(Apple Silicon 或 Intel)、Windows 10+(x64/x86/arm64)或 Linux x64/arm64。
Node.js 20+(仅安装器需要;安装完成后可卸载)。
一个你拥有凭据的上游目标:例如一个需要 Authorization 的下载 URL、一台 SSH 服务器、或一个 OpenAI/Anthropic 兼容 API。
建议先阅读安全模型 一章,理解 Airlock 的边界。
02
安装 Airlock
所有平台使用同一条命令安装。安装器会下载当前平台的固定校验和产物,SHA-256 校验失败时拒绝执行。
安装(首次安装请去掉 --open) ⧉ npm install -g airlock-relay
airlock-installer install --open
安装后建议立即校验一次安装器契约:
查看平台状态 ⧉ airlock-installer status --json
airlock-installer doctor
关于签名 macOS 包为 ad-hoc 签名且未经 Apple 公证,首次打开需要 Gatekeeper 确认;Windows/Linux 为未签名预览产物。请始终从官方 Release 下载并核对 SHA-256。
03
启动并了解界面
首次启动 Airlock Desktop 后,本地核心 airlockd 会自动运行:HTTP 入口默认监听 127.0.0.1:4768,SSH 入口监听 127.0.0.1:4770。关闭窗口不会停止转发服务;控制通道是当前用户专属的 Unix 套接字(Windows 为命名管道)。
左侧导航:概览 (核心状态与端口)、路由 (创建与管理入口)、活动 (脱敏请求记录)、设置 (网络范围、Secret 存储、代理与主题)。
04
创建第一条 HTTP 路由
在"路由"页点击新增路由 ,类型选择 HTTP / Wget ,填写:名称(如 release)、别名(releases)、上游基址(如 https://example.com/releases/)、允许的方法与查询参数。上游 Authorization 在 Airlock 窗口内录入,只发送到本机核心,不会进入日志。
服务端(无桌面)环境使用规格文件:
/etc/airlock/releases.json ⧉ {
"name": "Release mirror",
"alias": "releases",
"base_url": "https://example.com/releases/",
"authorization": "Bearer upstream-secret",
"methods": ["GET", "HEAD"],
"egress": "Auto"
}
创建并启用(CLI) ⧉ airlock --data-dir /var/lib/airlock --token-file /etc/airlock/control.token \
routes create http --file /etc/airlock/releases.json
airlock --data-dir /var/lib/airlock --token-file /etc/airlock/control.token \
routes enable releases
创建输出只出现一次 创建成功后终端会打印一次本地 capability。请立即把它交给调用方;它不会再次显示,也不要用命令行参数传递上游 Secret。
05
验证 HTTP 路由
调用方使用本地入口 127.0.0.1:4768/r/releases/... 和本地凭据,真实上游地址与 Authorization 不会出现在调用方一侧。
成功场景 ⧉ curl -H "Authorization: Bearer <local-token>" \
http://127.0.0.1:4768/r/releases/latest.zip -o latest.zip
预期失败场景 ⧉ curl -H "Authorization: Bearer wrong" http://127.0.0.1:4768/r/releases/latest.zip
# HTTP 401 invalid_api_key;不会泄露上游地址或真实凭据
在"活动"页应看到两条记录:一条 allowed、一条 blocked,均不包含 URL 与 Secret。
06
创建 SSH 路由
SSH 路由需要先探测上游 Host Key。桌面向导会引导完成:上游地址/账号/密码或私钥 → 本地用户名与本地密码 → Host Key 确认。CLI 路径如下:
探测 Host Key ⧉ airlock --data-dir /var/lib/airlock --token-file /etc/airlock/control.token \
ssh probe --address build.example:22 --egress Auto
# 输出 host_key,写入 0600 规格文件后创建
build.json ⧉ {
"name": "Build server",
"alias": "build",
"local_username": "build",
"upstream": "build.example:22",
"username": "deploy",
"password": "upstream-password",
"host_key": "ssh-ed25519 AAAA...",
"allowed_command": "deploy --release",
"egress": "Auto"
}
创建、健康检查并启用 ⧉ airlock ... routes create ssh --file /etc/airlock/build.json
airlock ... routes health build
airlock ... routes enable build
调用方连接:ssh build@127.0.0.1 -p 4770(输入本地密码)。默认只允许精确命令 deploy --release;需要交互式 Shell 时,在路由设置中开启"允许交互式 Shell"(同时要求开放所有命令,属高风险操作)。
07
创建 LLM 路由
coding.json ⧉ {
"name": "Coding",
"alias": "coding",
"base_url": "https://api.example.com/v1",
"authorization": "upstream-key",
"provider": "openai",
"models": ["model-a", "model-b"],
"max_output_tokens": 4096,
"requests_per_minute": 60,
"max_concurrent": 4,
"track_usage": true
}
创建成功后,CLI 会打印一次本地二次 API Key 。调用方这样使用:
客户端配置 ⧉ export OPENAI_BASE_URL=http://127.0.0.1:4768/r/coding
export OPENAI_API_KEY=<local-api-key>
模型白名单之外的请求返回 403 model_not_allowed;输出超过限额返回 400。用法统计只保留数字,不保存提示词或响应正文。
08
轮换与撤销凭据
轮换本地凭据 :桌面端"编辑路由 → 轮换";CLI 使用 routes rotate-credential。轮换后旧凭据立即失效。
撤销访问 :routes disable <alias> 停用路由但保留配置;routes delete <alias> 删除路由与相关 Secret。
紧急全停 :routes stop-all --yes 禁用所有路由,配置保留待审查。
建议 把轮换纳入例行操作:怀疑凭据泄露、人员变动或季度例行时执行。
Getting started: a working route in 15 minutes
This tutorial walks you through: install Airlock, launch the desktop, create and verify your first HTTP route, add SSH and LLM routes, then rotate and revoke credentials.
01 Prerequisites macOS 12+ (Apple Silicon or Intel), Windows 10+ (x64/x86/arm64), or Linux x64/arm64. Node.js 20+ (only needed by the installer). An upstream target you hold credentials for: a protected download URL, an SSH server, or an OpenAI/Anthropic-compatible API. We recommend reading the security model first.
02 Install Airlock One command installs on every platform. The installer downloads the pinned artifact for your platform and refuses to run on any SHA-256 mismatch.
Install (omit --open on first run) ⧉ npm install -g airlock-relay
airlock-installer install --openVerify the installer contract immediately:
Platform status ⧉ airlock-installer status --json
airlock-installer doctorSigning macOS is ad-hoc signed and not notarized (expect Gatekeeper); Windows/Linux are unsigned previews. Always download from the official release and verify the SHA-256.
03 Launch and orient The local core airlockd starts with the desktop: HTTP listens on 127.0.0.1:4768, SSH on 127.0.0.1:4770. Closing the window does not stop the relay. The control channel is a current-user Unix socket (or named pipe on Windows).
Left navigation: Overview (core state and ports), Routes (create and manage), Activity (sanitized records), Settings (network scope, secret store, proxy, theme).
04 Create your first HTTP route From Routes, click New route , choose HTTP / Wget , and fill in the name, alias, upstream base URL, and allowed methods/query keys. The upstream Authorization is entered inside the Airlock window and sent only to the local core, never logs.
Headless servers use a spec file:
/etc/airlock/releases.json ⧉ {
"name": "Release mirror",
"alias": "releases",
"base_url": "https://example.com/releases/",
"authorization": "Bearer upstream-secret",
"methods": ["GET", "HEAD"],
"egress": "Auto"
}Create and enable (CLI) ⧉ airlock --data-dir /var/lib/airlock --token-file /etc/airlock/control.token \
routes create http --file /etc/airlock/releases.json
airlock --data-dir /var/lib/airlock --token-file /etc/airlock/control.token \
routes enable releasesThe capability is printed once Creation prints the local capability exactly once. Hand it to the caller; it is never shown again, and upstream secrets must never appear in arguments.
05 Verify the HTTP route Callers use the local endpoint 127.0.0.1:4768/r/releases/... with their local credential. The upstream URL and Authorization stay hidden.
Success ⧉ curl -H "Authorization: Bearer <local-token>" \
http://127.0.0.1:4768/r/releases/latest.zip -o latest.zipExpected failure ⧉ curl -H "Authorization: Bearer wrong" http://127.0.0.1:4768/r/releases/latest.zip
# HTTP 401 invalid_api_key; no upstream or secret details leakActivity shows one allowed and one blocked record, both sanitized.
06 Create an SSH route SSH routes require probing the upstream host key first. The desktop wizard collects the upstream address/credentials, local username and password, then asks you to confirm the host key. CLI path:
Probe host key ⧉ airlock --data-dir /var/lib/airlock --token-file /etc/airlock/control.token \
ssh probe --address build.example:22 --egress Auto
# Write the returned host_key into a 0600 spec filebuild.json ⧉ {
"name": "Build server",
"alias": "build",
"local_username": "build",
"upstream": "build.example:22",
"username": "deploy",
"password": "upstream-password",
"host_key": "ssh-ed25519 AAAA...",
"allowed_command": "deploy --release",
"egress": "Auto"
}Create, health check, enable ⧉ airlock ... routes create ssh --file /etc/airlock/build.json
airlock ... routes health build
airlock ... routes enable buildCallers connect with ssh build@127.0.0.1 -p 4770 and enter the local password. Only the exact command deploy --release is allowed by default. For interactive shells, enable the interactive-shell switch together with all-commands permission (high risk).
07 Create an LLM route coding.json ⧉ {
"name": "Coding",
"alias": "coding",
"base_url": "https://api.example.com/v1",
"authorization": "upstream-key",
"provider": "openai",
"models": ["model-a", "model-b"],
"max_output_tokens": 4096,
"requests_per_minute": 60,
"max_concurrent": 4,
"track_usage": true
}Creation prints a local secondary API key once. Callers use:
Client configuration ⧉ export OPENAI_BASE_URL=http://127.0.0.1:4768/r/coding
export OPENAI_API_KEY=<local-api-key>Disallowed models return 403 model_not_allowed; oversized outputs return 400. Usage tracking keeps numbers only.
08 Rotate and revoke credentials Rotate : desktop "Edit route → Rotate" or routes rotate-credential. Old credentials stop working immediately.Revoke : routes disable <alias> keeps config but blocks access; routes delete <alias> removes the route and its secrets.Emergency stop : routes stop-all --yes disables every route while retaining configuration.
はじめに:15分で最初のルートを構築
このチュートリアルでは、Airlock のインストール、デスクトップの起動、最初の HTTP ルートの作成と検証、SSH/LLM ルートの追加、認証情報のローテーションと失効までを順に説明します。
01 前提条件 macOS 12+(Apple Silicon / Intel)、Windows 10+(x64/x86/arm64)、または Linux x64/arm64。 Node.js 20+(インストーラーのみで必要)。 認証情報を持つ上流ターゲット(保護付き URL、SSH サーバー、OpenAI/Anthropic 互換 API)。 セキュリティモデル を先に読むことを推奨します。
02 Airlock のインストール すべてのプラットフォームで同じコマンドを使います。インストーラーは固定 checksum 付きのアーティファクトをダウンロードし、SHA-256 不一致なら実行を拒否します。
インストール(初回は --open を外す) ⧉ npm install -g airlock-relay
airlock-installer install --open契約を確認 ⧉ airlock-installer status --json
airlock-installer doctor署名について macOS は ad-hoc 署名・未公証(Gatekeeper 確認あり)、Windows/Linux は未署名プレビューです。必ず公式 Release から取得し SHA-256 を確認してください。
03 起動と画面の確認 ローカルコア airlockd はデスクトップとともに起動します。HTTP は 127.0.0.1:4768、SSH は 127.0.0.1:4770 を既定で待ち受けます。ウィンドウを閉じてもリレーは停止しません。左メニュー:Overview / Routes / Activity / Settings。
04 最初の HTTP ルートを作成 Routes から「New route」→「HTTP / Wget」を選択し、名前・エイリアス・上流ベース URL・許可メソッドを入力します。上流の Authorization は Airlock ウィンドウ内で入力され、ローカルコアにのみ送信され、ログには入りません。
ヘッドレス環境では仕様ファイルを使います。
/etc/airlock/releases.json ⧉ {
"name": "Release mirror",
"alias": "releases",
"base_url": "https://example.com/releases/",
"authorization": "Bearer upstream-secret",
"methods": ["GET", "HEAD"],
"egress": "Auto"
}作成と有効化(CLI) ⧉ airlock --data-dir /var/lib/airlock --token-file /etc/airlock/control.token \
routes create http --file /etc/airlock/releases.json
airlock --data-dir /var/lib/airlock --token-file /etc/airlock/control.token \
routes enable releasescapability は一度だけ出力 作成時、ローカル capability は一度だけ表示されます。呼び出し元に渡し、再表示されることはありません。
05 HTTP ルートの検証 成功 ⧉ curl -H "Authorization: Bearer <local-token>" \
http://127.0.0.1:4768/r/releases/latest.zip -o latest.zip想定される失敗 ⧉ curl -H "Authorization: Bearer wrong" http://127.0.0.1:4768/r/releases/latest.zip
# HTTP 401 invalid_api_key。上流や認証情報は漏れませんActivity には allowed と blocked が 1 件ずつ記録されます。
06 SSH ルートを作成 まず上流の Host Key をプローブします。CLI の例:
Host Key プローブ ⧉ airlock --data-dir /var/lib/airlock --token-file /etc/airlock/control.token \
ssh probe --address build.example:22 --egress Autobuild.json ⧉ {
"name": "Build server",
"alias": "build",
"local_username": "build",
"upstream": "build.example:22",
"username": "deploy",
"password": "upstream-password",
"host_key": "ssh-ed25519 AAAA...",
"allowed_command": "deploy --release",
"egress": "Auto"
}呼び出し元は ssh build@127.0.0.1 -p 4770 で接続します(ローカルパスワード入力)。既定では deploy --release のみ許可。対話型シェルが必要なら「すべてのコマンド」と合わせて明示的に有効化します。
07 LLM ルートを作成 coding.json ⧉ {
"name": "Coding",
"alias": "coding",
"base_url": "https://api.example.com/v1",
"authorization": "upstream-key",
"provider": "openai",
"models": ["model-a", "model-b"],
"max_output_tokens": 4096,
"requests_per_minute": 60,
"max_concurrent": 4,
"track_usage": true
}作成時にローカル二次 API Key が一度だけ出力されます。クライアントは OPENAI_BASE_URL=http://127.0.0.1:4768/r/coding と OPENAI_API_KEY を設定します。許可外モデルは 403、出力超過は 400 になります。
08 認証情報のローテーションと失効 ローテーション :デスクトップ「Edit route → Rotate」または routes rotate-credential。旧認証情報は即時無効。失効 :routes disable <alias> で停止(設定は保持)、routes delete <alias> で削除。緊急停止 :routes stop-all --yes。