diff --git a/README.md b/README.md new file mode 100644 index 0000000..91c2151 --- /dev/null +++ b/README.md @@ -0,0 +1,95 @@ +# Claw + +云主机管理工具,命令行搞定 SSH 连接、脚本执行、文件分发。 + +## 目录结构 + +``` +Claw/ +├── claw.bat # 入口 (PowerShell 包装器) +├── claw.ps1 # 主控脚本 +├── hosts/ # 主机描述文件 +├── keys/ # SSH 私钥 (.pem) +├── scripts/ # 可执行脚本 +└── payloads/ # 待分发文件 +``` + +## 命令 + +```cmd +claw list # 列出所有主机 +claw ssh <主机名> # SSH 连接 +claw run <主机名> <脚本名> # 执行脚本 +claw push <主机名> <文件或目录> # 推送文件到 /tmp/ +claw key add <名称> # 注册密钥 +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= +USER= +PORT= +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/` 下。 + +## 快速开始 + +```cmd +# 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`: + +```powershell +[Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", "User") + ";C:\Code\Claw", "User") +``` diff --git a/hosts/example-ubuntu-root b/hosts/example-ubuntu-root deleted file mode 100644 index 3b86ede..0000000 --- a/hosts/example-ubuntu-root +++ /dev/null @@ -1,33 +0,0 @@ -# ╔══════════════════════════════════════════════════╗ -# ║ example-server · 示例主机 ║ -# ╚══════════════════════════════════════════════════╝ -# -# --- 基本信息 --- -# 实例名称 example-server -# 实例 ID lhins-xxxxxxxx -# 状态 运行中 -# 地域 北京 · 北京七区 -# -# --- 配置 --- -# CPU 4 核 -# 内存 4 GB -# 系统盘 SSD 云硬盘 40 GB -# 镜像 Ubuntu Server 24.04 LTS 64bit -# -# --- 网络 --- -# 公网 IPv4 1.2.3.4 -# 内网 IPv4 10.0.0.1 -# 带宽 3 Mbps -# 流量包 300 GB/月 -# -# --- 密钥 --- -# 密钥 ID lhkp-xxxxxxxx -# -# --- 费用 --- -# 到期时间 2027-01-01 -# 自动续费 未开启 - -HOST=1.2.3.4 -USER=root -PORT=22 -KEY=keys/example.pem diff --git a/hosts/tx-ubuntu-hugo b/hosts/tx-ubuntu-hugo index 01bc797..1533709 100644 --- a/hosts/tx-ubuntu-hugo +++ b/hosts/tx-ubuntu-hugo @@ -1,8 +1,31 @@ # ╔══════════════════════════════════════════════════╗ -# ║ tx-ubuntu-hugo · 同主机 hugo 用户 ║ +# ║ tx-ubuntu · 腾讯云轻量应用服务器 (hugo 用户) ║ # ╚══════════════════════════════════════════════════╝ # -# 与 tx-ubuntu-ubuntu 同一台机器,仅用户不同 +# 与 tx-ubuntu-ubuntu 同一台机器,仅 SSH 用户不同 +# +# --- 基本信息 --- +# 实例名称 tx_ubuntu_62.234.90.54@20260512 +# 实例 ID lhins-61pjmw9y +# 状态 运行中 +# 地域 北京 · 北京七区 +# +# --- 配置 --- +# CPU 4 核 +# 内存 4 GB +# 系统盘 SSD 云硬盘 40 GB +# 镜像 OpenClaw(龙虾) · Ubuntu Server 24.04 LTS 64bit +# +# --- 网络 --- +# 公网 IPv4 62.234.90.54 +# 内网 IPv4 10.2.0.9 +# 带宽 3 Mbps +# 流量包 300 GB/月(每月 13 日重置) +# IPv6 不支持 +# +# --- 费用 --- +# 到期时间 2027-05-12 13:49:28 +# 自动续费 未开启 HOST=62.234.90.54 USER=hugo diff --git a/scripts/install-docker.sh b/scripts/install-docker.sh deleted file mode 100644 index 46fdd60..0000000 --- a/scripts/install-docker.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash -# 安装 Docker (Ubuntu/Debian) -set -e - -echo ">>> 安装 Docker..." - -# 卸载旧版本 -apt-get remove -y docker docker-engine docker.io containerd runc 2>/dev/null || true - -# 安装依赖 -apt-get update -apt-get install -y ca-certificates curl gnupg - -# 添加 Docker GPG 密钥 -install -m 0755 -d /etc/apt/keyrings -curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg -chmod a+r /etc/apt/keyrings/docker.gpg - -# 添加源 -echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null - -# 安装 -apt-get update -apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin - -echo ">>> Docker 安装完成" -docker --version diff --git a/scripts/hello.sh b/scripts/sysinfo@tx-ubuntu-ubuntu.sh similarity index 100% rename from scripts/hello.sh rename to scripts/sysinfo@tx-ubuntu-ubuntu.sh