Files
claw/README.md
T
fukunee 1904288e9b Add README documentation and clean up project files
Remove unused example host file and Docker install script, rename
hello.sh to follow naming convention, and add comprehensive README with
project structure, commands, and usage examples
2026-05-13 14:48:25 +08:00

2.1 KiB
Raw Blame History

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

文件内容:

HOST=<IP或域名>
USER=<SSH用户名>
PORT=<SSH端口>
KEY=keys/<密钥文件>.pem

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. 写主机描述
notepad hosts\my-host-ubuntu-root

# 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")