Claw

云主机管理工具,命令行搞定 SSH 连接、脚本执行、文件分发。

目录结构

Claw/
├── claw.bat                # 入口 (PowerShell 包装器)
├── claw.ps1                # 主控脚本
├── hosts/                  # 主机描述文件
├── keys/                   # SSH 私钥 (.pem)
├── scripts/                # 可执行脚本
└── payloads/               # 待分发文件

命令

claw list                              # 列出所有主机
claw ssh <主机名>                       # SSH 连接
claw run <主机名> <脚本名>              # 执行脚本
claw push <主机名> <文件或目录>         # 推送文件到 /tmp/
claw key add <名称> <pem文件路径>       # 注册密钥
claw key list                          # 列出密钥

命名格式

hosts/ — 主机描述

<主机标识>-<操作系统>-<用户名>

例:tx-ubuntu-ubuntu = 腾讯云主机 · Ubuntu · ubuntu 用户

同一台机器的不同用户用独立文件:

tx-ubuntu-ubuntu    # → 62.234.90.54 用户 ubuntu
tx-ubuntu-hugo      # → 62.234.90.54 用户 hugo

YAML 格式(.yml 后缀),新建主机复制下面模板改:

# ╔══════════════════════════════════════════════════╗
# ║  example  ·  示例主机                             ║
# ╚══════════════════════════════════════════════════╝

host:
  ip: 1.2.3.4
  user: root
  port: 22
  key: keys/example.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/ — 密钥

<主机名>.pem

例:tx-ubuntu.pem、tx-ubuntu-hugo.pem

payloads/ — 发射区

把要发上主机的文件或目录扔进来,claw push 会走 SCP 发到主机的 /tmp/ 下。

快速开始

# 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
claw push my-host-ubuntu-root my-project

全局命令

把项目路径加入 PATH 即可在任何目录使用 claw:

[Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", "User") + ";C:\Code\Claw", "User")
S
Description
No description provided
Readme
3.5 MiB
Languages
Shell 74.7%
PowerShell 25.1%
Batchfile 0.2%