Install
openclaw skills install aliyun-ecs-skillManage Alibaba Cloud ECS (Elastic Compute Service) — query instances, monitoring, firewall, snapshots, remote execution. Use when user asks about ECS, 阿里云服务器, or Alibaba Cloud. NOT for Tencent Cloud or other cloud providers.
openclaw skills install aliyun-ecs-skill管理阿里云ECS(弹性计算服务)实例。
当用户首次要求管理阿里云服务器时,按以下流程操作:
{baseDir}/scripts/setup.sh --check-only
如果输出显示一切 OK(SDK 已安装、config 已配置、ECS 已就绪),跳到「调用格式」。
告诉用户:
我需要你的阿里云 API 密钥来连接 ECS 服务器。请提供:
- AccessKey ID — 阿里云 API 密钥 ID
- AccessKey Secret — 阿里云 API 密钥 Secret
你可以在 阿里云控制台 > 访问控制 > AccessKey管理 获取。
⚠️ 建议使用子账号,只授予ECS相关权限(ecs:*)
{baseDir}/scripts/setup.sh --access-key-id "<用户提供的AccessKeyId>" --access-key-secret "<用户提供的AccessKeySecret>"
脚本会自动:
~/.aliyun/config.json 配置文件设置完成后即可开始使用。
所有命令使用以下格式:
aliyun-ecs <command> [options]
或直接使用 Node.js 脚本:
node {baseDir}/src/index.js <command> [options]
| 类别 | 说明 |
|---|---|
| 地域查询 | 获取可用地域列表 |
| 实例管理 | 查询、启动、停止、重启实例 |
| 监控与告警 | 获取多指标监控数据 |
| 快照管理 | 创建、删除、回滚快照 |
| 安全组 | 规则增删改查 |
| 远程命令 | 在实例上执行命令 |
aliyun-ecs regions
# 查询实例列表
aliyun-ecs list --region cn-hangzhou
# 查询指定实例
aliyun-ecs info --region cn-hangzhou --id i-xxxxxxxxxx
# 启动实例
aliyun-ecs start --region cn-hangzhou --id i-xxxxxxxxxx
# 停止实例
aliyun-ecs stop --region cn-hangzhou --id i-xxxxxxxxxx
# 重启实例
aliyun-ecs restart --region cn-hangzhou --id i-xxxxxxxxxx
# 获取监控数据(CPU、内存、网络)
aliyun-ecs monitor --region cn-hangzhou --id i-xxxxxxxxxx --metrics CPUUtilization,MemoryUtilization
# 支持的监控指标:
# CPUUtilization - CPU使用率
# MemoryUtilization - 内存使用率
# InternetInRate - 公网入带宽
# InternetOutRate - 公网出带宽
# DiskReadIOPS - 磁盘读IOPS
# DiskWriteIOPS - 磁盘写IOPS
# 创建快照
aliyun-ecs snapshot create --region cn-hangzhou --id i-xxxxxxxxxx --name "backup-20260312"
# 列出快照
aliyun-ecs snapshot list --region cn-hangzhou --id i-xxxxxxxxxx
# 删除快照
aliyun-ecs snapshot delete --region cn-hangzhou --snapshot-id s-xxxxxxxxxx
# 回滚快照
aliyun-ecs snapshot rollback --region cn-hangzhou --id i-xxxxxxxxxx --snapshot-id s-xxxxxxxxxx
# 查询安全组规则
aliyun-ecs security-group list --region cn-hangzhou --group-id sg-xxxxxxxxxx
# 添加安全组规则(开放80端口)
aliyun-ecs security-group add --region cn-hangzhou --group-id sg-xxxxxxxxxx --port 80 --protocol tcp
# 删除安全组规则
aliyun-ecs security-group remove --region cn-hangzhou --group-id sg-xxxxxxxxxx --port 80 --protocol tcp
# 在 Linux 实例上执行命令
aliyun-ecs exec --region cn-hangzhou --id i-xxxxxxxxxx --command "uptime && df -h && free -m"
# 在 Windows 实例上执行命令
aliyun-ecs exec --region cn-hangzhou --id i-xxxxxxxxxx --command "Get-Process | Sort-Object CPU -Descending | Select-Object -First 10" --windows
regions 外,所有操作都必须传入 --region 参数regions 获取地域列表 → 再调用 list 获取实例列表 → 记住 InstanceId 和 Region 供后续使用setup.sh --check-only 诊断问题