安装与下载
1 ClawHub CLI
从源直接安装技能的最快方式。
npx clawhub@latest install swap-setup
2 手动安装
将技能文件夹复制到以下位置之一
~/.openclaw/skills/
{'/skills/'}
优先级:工作区 › 全局 › 内置
3 提示词安装
将此提示词复制到 Openclaw 即可自动安装。
请帮我使用 Clawhub 安装 skill-swap-setup。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。
更倾向于下载?
获取包含原生技能文件的ZIP压缩包。
基本信息
swap-setup
安装指南
- ClawHub CLI
从源直接安装技能的最快方式。
npx clawhub@latest install swap-setup - 手动安装
将技能文件夹复制到以下位置之一
全局模式
~/.openclaw/skills/
工作区
/skills/
优先级:工作区 > 本地 > 内置 - 提示词安装
将此提示词复制到 OpenClaw 即可自动安装。
请帮我使用 Clawhub 安装 swap-setup。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。
更倾向于下载?
获取包含原生技能文件的ZIP压缩包。
下载技能 (.zip)
什么是
swap-setup helps VPS owners add a swap file without opening a terminal or running commands themselves. The agent guides the owner through adding a temporary public key in the VPS provider panel, then uses key-based SSH access to create and activate swap and configure it to return after a reboot.
This Openclaw Skills entry is deliberately narrow and security-conscious: it requires owner verification and informed consent before making system changes, backs up and validates /etc/fstab, and removes the single-use key after completion. It is intended only for the requested swap setup—not software installation, unrelated service changes, data access, or SSH configuration changes.
应用场景
A VPS owner reports memory pressure or asks to add swap to a low-RAM server.
The owner requests a specific swap size, such as 2 GB, and prefers not to use a terminal.
The owner wants swap configured to persist across reboots.
The agent needs to check existing swap and available disk space before making a change.
A VPS provider offers SSH-key management or a web console that lets the owner add the agent's public key.
工作原理
Verify and get consent: Confirm the requester is the VPS owner. Explain that SSH access with sudo or root privileges is needed, /swapfile will be created, and /etc/fstab will be changed. Wait for explicit approval.
Collect connection details: Obtain the host or IP, SSH port (default 22 if unspecified), login user, desired swap size, and provider name if available. Ask for missing details rather than guessing.
Create a dedicated temporary key: Generate a unique Ed25519 key pair for this task. Share only the public key and guide the owner to add it in the VPS panel; wait for confirmation before connecting.
Test SSH access: Connect with the temporary key and verify access before proceeding. If authentication fails, check the key, username, and port; do not continue without a working connection.
Inspect the VPS: Detect the operating system, architecture, memory, existing swap, disk capacity, and user identity. Check sudo access separately. Stop if disk space is insufficient or existing swap makes the requested change unnecessary without further approval.
Create and activate swap: If /swapfile already exists, do not overwrite it. Otherwise create the requested file with fallocate, falling back to dd if the filesystem does not support allocation; set restrictive permissions, run mkswap, and enable it with swapon.
Configure persistence safely: Back up /etc/fstab, check for an existing swap entry, and append exactly one /swapfile entry only if needed. Validate the configuration before any reboot; restore the backup and stop if validation fails.
Verify and revoke access: Confirm swap with swapon --show and free -m. Delete the task-specific key pair from the agent machine and instruct the owner to remove its public key from the VPS panel.
Report completion: Summarize the swap size, verification results, fstab validation, and key revocation. Do not expose secrets or tokens in chat.
配置指南
Installation note: The supplied skill file does not specify a package installation command or a required OpenClaw directory. Install or enable it according to the conventions of your OpenClaw environment; do not assume extra dependencies.
Before starting, the agent needs a secure local ~/.ssh directory and command execution capability. Collect the VPS host, port, login user, requested swap size, and—if known—the provider panel. The requester must be the owner or have verified owner authorization. Explain the system changes and obtain explicit consent before generating a key or connecting. The owner must be able to add the public key through the provider panel or web console.
The following commands illustrate the skill's task-specific key lifecycle; they are agent-side commands, not instructions for the owner to run in a terminal:
ssh-keygen -t ed25519 -N "" -f ~/.ssh/swap_setup_ed25519 -C "swap-setup-single-use"
cat ~/.ssh/swap_setup_ed25519.pub
After the owner confirms the public key is installed, test SSH with the provided host, port, and user:
ssh -i ~/.ssh/swap_setup_ed25519 -o BatchMode=yes -o StrictHostKeyChecking=accept-new -p
@ 'echo CONNECT_OK'
Proceed only after a successful connection and verified sudo or root access. Never request or transmit a password or private key. Once the swap is verified, remove the temporary key pair from the agent machine and guide the owner to remove the corresponding key from the VPS panel.
数据架构
The skill does not define a structured database or metadata taxonomy. Its operational files and system locations are:
Location Purpose Handling
~/.ssh/swap_setup_ed25519 Dedicated, task-specific private key Keep private; delete after successful setup.
~/.ssh/swap_setup_ed25519.pub Public key provided to the owner for the VPS panel Remove from the agent machine after the task and ask the owner to remove it from the panel.
/swapfile Swap file created on the VPS Do not overwrite if it already exists. Set permissions to 600; remove only as part of an explicitly requested rollback.
/etc/fstab Persistent swap configuration Back up before editing; append one swap entry only if absent; validate before considering the change complete.
/etc/fstab.bak. Timestamped backup created before editing fstab Use to restore the original configuration if validation fails.
The workflow also reads system information such as /etc/os-release, uname -m, free -m, swapon --show, /proc/swaps, df -h /, and id to assess the operating system, memory, existing swap, disk space, and user. It does not define persistent task logs or application data files.
高级特性
Single-use SSH access:
Uses a task-specific Ed25519 key, shares only its public half, and requires cleanup on both the agent and provider-panel sides.
Owner approval gate:
Requires identity confirmation and explicit consent before privileged operations that change the VPS.
Preflight checks:
Detects OS, memory, current swap, available disk space, and privilege level; stops on unsafe or ambiguous conditions.
Adaptive swap-file creation:
Prefers
fallocate
and falls back to
dd
when the filesystem does not support allocation; refuses to overwrite an existing
/swapfile
.
Protected fstab workflow:
Creates a timestamped backup, checks for duplicate swap entries, validates the result, and requires restoration and a stop if validation fails.
Provider-aware guidance:
Uses the known VPS provider to help the owner find SSH-key settings, with the provider's web console as an alternative where appropriate.
Verification and rollback guidance:
Checks active swap and memory after setup; documents how to disable swap, remove its fstab entry, and delete the swap file if rollback is needed.
Strict scope boundaries:
Does not install software, change unrelated services or SSH configuration, access user data, or retain access credentials.
name: "swap-setup" description: ""Thêm swap cho VPS qua chat, không cần terminal: agent sinh SSH key dùng một lần, người dùng dán public key vào panel, agent tạo swap.""
swap-setup — Thêm swap cho VPS qua chat (không cần terminal)
Giúp người dùng không rành kỹ thuật thêm dung lượng swap cho VPS mà không phải gõ lệnh. Người dùng chỉ làm một việc duy nhất bằng click chuột (dán public key vào panel VPS).
⚠️ CẢNH BÁO — ĐỌC KỸ TRƯỚC KHI CHẠY
Việc này thay đổi hệ thống của VPS:
Agent cần quyền SSH (qua key) vào VPS để chạy lệnh với quyền sudo/root.
Agent sẽ sửa /etc/fstab (thêm 1 dòng cho swap) — file ảnh hưởng tới lúc khởi động máy.
Agent sẽ tạo/xóa file /swapfile trên ổ đĩa của VPS.
Chỉ chạy khi người dùng hiểu và đồng ý. Agent phải nêu rõ các điểm trên và chờ người dùng xác nhận trước khi làm.
Phạm vi (scope) — chỉ đúng việc này:
Tạo một swapfile và bật nó.
Thêm đúng 1 dòng vào /etc/fstab để swap tự bật lại sau reboot.
Không cài phần mềm, không đụng dữ liệu, không sửa dịch vụ khác, không đổi cấu hình SSH.
🔑 CƠ CHẾ: KEY-ONLY, DÙNG MỘT LẦN (THU HỒI SAU KHI XONG). Agent tự tạo một cặp SSH key dùng riêng cho việc này. Agent giữ private key, chỉ đưa public key cho người dùng. Người dùng copy public key rồi dán vào ô SSH Keys trong panel quản trị VPS (Vultr, DigitalOcean, AWS Lightsail, aCloud, Vietnix, AZDIGI, ...). Không có bí mật nào đi qua chat; không có mật khẩu; người dùng không mở terminal.
⏹ Thu hồi khi xong (bắt buộc): sau khi tạo swap thành công, agent xóa cặp key dùng riêng cho việc này khỏi máy agent và hướng dẫn người dùng xóa key đó khỏi panel VPS. Key sinh ra chỉ để chạy một lần, không giữ lại quyền truy cập thường trực.
Khi nào dùng
Người dùng nói kiểu:
"VPS em yếu quá, thêm swap giúp"
"Máy 1GB RAM, tạo swap 2GB"
"Cài swap cho VPS giúp em, em không biết dùng terminal"
"Thêm swap mà không cần mở SSH"
Input cần thu thập (từ người dùng)
Host/IP VPS (số hoặc tên miền).
Port (mặc định 22 nếu không nói).
User đăng nhập (thường root, hoặc user có sudo; nếu không rõ → hỏi hoặc thử root).
Swap size mong muốn (nếu không nói → mặc định theo RAM: RAM ≤2GB → swap = 2× RAM, cap 4GB; RAM >2GB → swap = RAM, cap 4GB; RAM ≥8GB → 2–4GB).
Nhà cung cấp VPS (nếu biết) → để hướng dẫn đúng giao diện panel.
Nếu thiếu host/user → hỏi lại đúng cái thiếu. KHÔNG tự đoán IP.
Quy trình agent PHẢI làm (theo đúng thứ tự)
Bước 0 — Xác nhận danh tính + xin đồng ý
Chỉ thực thi khi người yêu cầu là owner. Nếu không chắc → hỏi xác nhận trước.
Nêu rõ cảnh báo ở đầu bài (SSH + sudo/root + sửa /etc/fstab + tạo/xóa /swapfile) và chờ người dùng đồng ý.
Nói rõ: "Em sẽ tạo swap giúp anh/chị. Anh/chị chỉ cần copy đoạn key em đưa rồi dán vào mục SSH Keys trong panel VPS. Xong việc em hướng dẫn xóa key đó đi."
Bước 1 — Tạo cặp key DÙNG RIÊNG + đưa public key
Tạo key riêng, đặt tên riêng để xóa dễ (không ghi đè key khác):
ssh-keygen -t ed25519 -N "" -f ~/.ssh/swap_setup_ed25519 -C "swap-setup-single-use"
Gửi nội dung public key cho người dùng:
cat ~/.ssh/swap_setup_ed25519.pub
Hướng dẫn người dùng (không cần terminal):
Mở panel quản trị VPS → tìm mục SSH Keys / SSH Public Keys / Access.
Bấm Add SSH Key → dán toàn bộ dòng public key → Save.
Nếu panel không có mục thêm key cho máy đang chạy → dùng mục SSH Keys áp cho máy, hoặc giao diện web console của panel để dán key.
Chờ người dùng xác nhận "đã dán xong".
Bước 2 — Kết nối bằng key
ssh -i ~/.ssh/swap_setup_ed25519 -o BatchMode=yes -o StrictHostKeyChecking=accept-new -p
@ 'echo CONNECT_OK'
Thấy CONNECT_OK → đi tiếp.
Chưa được → kiểm tra: key đã dán đúng chưa, user/port đúng chưa. KHÔNG đi tiếp khi chưa vào được.
Bước 3 — Nhận diện hệ điều hành (auto-detect)
cat /etc/os-release
uname -m
free -m
swapon --show
cat /proc/swaps
df -h /
id
Kiểm tra quyền nâng cấp, một lệnh riêng (không ghép chuỗi):
sudo -n true
(trả về 0 = có sudo; khác 0 = cần xử lý quyền.)
Distro: Ubuntu / Debian (chính). Với CentOS/RHEL/Alma/Rocky → cùng lệnh fallocate/dd + mkswap.
Nếu đã có swap đủ lớn → báo người dùng, chỉ tắt/giảm nếu có yêu cầu rõ.
Nếu thiếu dung lượng đĩa cho swap → DỪNG, báo thiếu, đề xuất size nhỏ hơn.
Bước 4 — Tạo file swap (an toàn)
# size tính bằng MB, ví dụ SWAP_MB=2048
sudo fallocate -l ${SWAP_MB}M /swapfile
# nếu fallocate lỗi mới dùng: sudo dd if=/dev/zero of=/swapfile bs=1M count=${SWAP_MB} status=progress
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
swapon --show
free -m
Nếu /swapfile đã tồn tại → KHÔNG ghi đè; báo người dùng và đặt tên khác (/swapfile2) hoặc xử lý theo yêu cầu.
Ưu tiên fallocate; nếu FS không hỗ trợ (một số FS ngoài ext4) → fallback dd.
Bước 5 — Bật swap vĩnh viễn (fstab — ĐIỂM DỄ SAI NHẤT)
KHÔNG ghi đè cả /etc/fstab. Phải:
Backup: sudo cp /etc/fstab /etc/fstab.bak.$(date +%F-%H%M)
Kiểm tra đã có dòng /swapfile chưa (tránh trùng): grep -nE '^[^#]*swap' /etc/fstab
Chỉ append nếu CHƯA có: echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
VALIDATE trước khi reboot — BẮT BUỘC: sudo findmnt --verify --verbose (hoặc sudo mount -a — lỗi thì DỪNG và khôi phục backup) sudo swapon -a để chắc chắn nạp lại không lỗi.
Nếu mount -a báo lỗi → restore fstab.bak ngay, báo người dùng. Sai fstab = máy không boot.
(Khuyến nghị) giảm swappiness: đặt vm.swappiness=10 qua /etc/sysctl.d/99-swap.conf, rồi sudo sysctl --system.
Bước 6 — THU HỒI KEY (bắt buộc — không để lại quyền truy cập thường trực)
Kiểm tra swap đã bật ổn: swapon --show + free -m.
Xóa cặp key dùng riêng khỏi máy agent:
rm -f ~/.ssh/swap_setup_ed25519 ~/.ssh/swap_setup_ed25519.pub
Hướng dẫn người dùng xóa key khỏi panel VPS (mục SSH Keys → Remove/Xóa key vừa thêm).
Xác nhận lại swap vẫn chạy sau khi thu hồi (swap không phụ thuộc key).
Nếu người dùng muốn agent kiểm tra lại sau này → tạo key mới theo quy trình này, không giữ key cũ.
Bước 7 — Báo cáo
Báo ngắn gọn: swap đã bật (size, free -m sau khi xong), fstab đã validate, key đã thu hồi.
Nhắc: "Anh/chị nhớ vào panel xóa key vừa dán nhé. Xong rồi, máy đã có swap."
KHÔNG echo bí mật/token nào ra chat.
Xử lý tình huống hay gặp
Tình huống Cách xử lý
Kết nối báo Permission denied Key chưa dán đúng / sai user/port → hướng dẫn lại, kiểm tra panel.
VPS không có panel SSH key Hướng dẫn dán public key qua giao diện web console của panel.
fallocate lỗi FS Dùng dd if=/dev/zero of=/swapfile bs=1M count=N status=progress.
swapon báo đã có swap Báo người dùng, hỏi muốn tăng hay giữ nguyên.
mount -a báo lỗi Restore fstab.bak NGAY; sửa lại cú pháp; validate lại.
User không có sudo Hỏi thông tin admin hoặc dùng sudo có sẵn.
Sai tên nhà cung cấp panel Hỏi lại tên panel để hướng dẫn đúng mục SSH Keys.
Rolling back (nếu cần)
Tắt swap: sudo swapoff /swapfile → xóa dòng trong fstab → sudo rm /swapfile.
Bảo mật — BẮT BUỘC
Chỉ nhận thông tin kết nối từ owner. Xác nhận danh tính trước khi kết nối.
Chỉ dùng key, dùng một lần. Không nhận, không dùng, không lưu mật khẩu.
Tạo key riêng biệt cho việc này; xóa key sau khi xong; hướng dẫn người dùng xóa key khỏi panel.
Private key agent giữ kín; chỉ gửi public key. Public key không phải bí mật.
KHÔNG echo bí mật/token trong câu trả lời; không ghi ra file ngoài ~/.ssh.
Không chạy lệnh phá hoại; không xóa dữ liệu; không đụng dịch vụ khác ngoài việc tạo swap.
Không tự ý đổi size/cấu hình khác ngoài yêu cầu.
Ghi chú kỹ thuật
Tạo key: ssh-keygen -t ed25519 -N "" -f
(không passphrase, phục vụ tự động hóa).
Test kết nối: -o BatchMode=yes để tránh treo; -o StrictHostKeyChecking=accept-new cho lần đầu.
fallocate nhanh nhưng một số FS (ZFS, một số XFS) có thể lỗi → dd chậm hơn nhưng chắc.
Tách riêng từng lệnh; mỗi bước validate kết quả trước khi sang bước sau.
miRNA靶点工具