da85314601d98cf121b40df38fc51dd89d051c60
Claw
云主机管理工具,命令行搞定 SSH 连接、脚本执行。
目录结构
Claw/
├── claw.bat # 入口 (PowerShell 包装器)
├── claw.ps1 # 主控脚本
├── hosts/ # 主机描述文件 (.yml)
├── keys/ # SSH 私钥 (.pem)
└── scripts/ # 可执行脚本 (.sh)
命令
claw list # 列出所有主机
claw ssh <主机名> # SSH 连接
claw run <主机名> <脚本名> # 执行脚本
claw key add <名称> <pem文件路径> # 注册密钥
claw key list # 列出密钥
tx-ubuntu 服务器概况
腾讯云轻量应用服务器 · 北京七区 · 4核4G · SSD 40G + 数据盘 20G
用户
| 用户 | 用途 |
|---|---|
| ubuntu | 系统管理、OpenClaw 运维 |
| hugo | Hugo 博客构建 (nginx 托管) |
| cmcc | Work 项目同步 |
| git | Git 裸仓库托管 |
| bitwarden | Vaultwarden 密码服务 |
服务
| 服务 | 端口 | 用户 | 说明 |
|---|---|---|---|
| OpenClaw | 17581 (内) | root | AI 网关 + 微信 bot |
| Hugo 博客 | 80/443 | hugo | ~/hugo-blog → nginx → public |
| Vaultwarden | 8443 | bitwarden | Docker 容器,数据 /data/vaultwarden |
| Git 仓库 | 22 | git | 裸仓库 /data/git-repos/Work.git |
| Nginx | 80/443/8443 | root | 反向代理,www-data worker |
| SSH | 22 | — | 所有用户密钥登录 |
| tat_agent | — | root | 腾讯云自动化助手 |
磁盘
| 挂载点 | 设备 | 大小 | 用途 |
|---|---|---|---|
| / | vda2 | 40G | 系统盘 |
| /data | vdb | 20G | 数据盘 (Git/Vaultwarden/Work) |
脚本
| 脚本 | 主机 | 说明 |
|---|---|---|
| sysinfo@tx-ubuntu-ubuntu.sh | ubuntu | 系统健康速览 |
| sync-blog@tx-ubuntu-hugo.sh | hugo | 拉代码 + Hugo 构建 |
| git-repo-create@tx-ubuntu-git.sh | git | 创建裸仓库 |
命名格式
hosts/ — 主机描述
<主机标识>-<操作系统>-<用户名>.yml
例:tx-ubuntu-ubuntu.yml = 腾讯云主机 · Ubuntu · ubuntu 用户
同一台机器的不同用户用独立文件:
tx-ubuntu-ubuntu.yml # → 62.234.90.54 用户 ubuntu
tx-ubuntu-hugo.yml # → 62.234.90.54 用户 hugo
tx-ubuntu-cmcc.yml # → 62.234.90.54 用户 cmcc
tx-ubuntu-git.yml # → 62.234.90.54 用户 git
YAML 格式,新建主机复制下面模板改:
# ╔══════════════════════════════════════════════════╗
# ║ example · 示例主机 ║
# ╚══════════════════════════════════════════════════╝
host:
ip: 1.2.3.4
user: root
port: 22
key: keys/example-ubuntu-root.pem
info:
name: example-server
id: lhins-xxxxxxxx
status: 运行中
region:
city: 北京
zone: 北京七区
spec:
cpu: 4核
memory: 4GB
disk: SSD云硬盘 40GB
image: Ubuntu 24.04 LTS
network:
public_ip: 1.2.3.4
private_ip: 10.0.0.1
bandwidth: 3Mbps
traffic: 300GB/月
billing:
expire: 2027-01-01
auto_renew: false
scripts/ — 脚本
<用途>@<主机名>.sh
例:sysinfo@tx-ubuntu-ubuntu.sh = 系统信息脚本 → 用于 tx-ubuntu-ubuntu
keys/ — 密钥
与 hosts 文件名一一对应:
tx-ubuntu-ubuntu.pem
tx-ubuntu-hugo.pem
tx-ubuntu-cmcc.pem
tx-ubuntu-git.pem
tx-ubuntu-bitwarden.pem
快速开始
# 1. 注册密钥
claw key add my-host C:\Users\me\Downloads\key.pem
# 2. 写主机描述 (YAML 格式)
notepad hosts\my-host-ubuntu-root.yml
# 3. 开工
claw ssh my-host-ubuntu-root
claw run my-host-ubuntu-root sysinfo@my-host-ubuntu-root.sh
全局命令
把项目路径加入 PATH 即可在任何目录使用 claw:
[Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", "User") + ";C:\Code\Claw", "User")
TODO
- 域名备案完成后 nginx 二级域名分流
blog.fukun.net→ Hugo 博客 (:443)vault.fukun.net→ Vaultwarden (:8443)git.fukun.net→ Git 仓库- 全部统一 443 nginx 按 server_name 分发
Languages
Shell
74.7%
PowerShell
25.1%
Batchfile
0.2%