Skip to content

Latest commit

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Linux Server Ops — AI Agent Skill

Language / 语言: English | 简体中文


An AI agent skill that turns your coding assistant into a full-featured Linux server management panel — like BaoTa / 1Panel, but driven entirely by AI over SSH.

Install in Claude Code

# In Claude Code, run:
/plugin marketplace add michael-ltm/linux-server-skill
/plugin install linux-server-skill@linux-server-skill

Restart Claude Code (or start a new session). Ask the agent to deploy, monitor, or manage a Linux server and the linux-server-ops skill auto-loads.

ActionCommand
Update/plugin update linux-server-skill@linux-server-skill
Uninstall/plugin uninstall linux-server-skill@linux-server-skill
View status/plugin

Chinese install docs: README.zh.md

What It Does

CategoryCapabilities
DeployStatic sites, Node.js (PM2), Java (systemd), Python (Gunicorn/Uvicorn), Go (systemd), PHP (FPM), Docker Compose
Domain & SSLNginx vhost generation, Let's Encrypt auto-issue & auto-renew, wildcard certs
DatabasesMySQL/MariaDB, PostgreSQL, Redis, MongoDB — create, manage, backup
DockerContainers, Compose stacks, registry, image management
WAF & FirewallModSecurity + OWASP CRS, Nginx rate limiting, IP blocklist, fail2ban, UFW/firewalld
MonitoringSystem metrics, PM2/systemd health, SSL expiry, uptime watchdog, alerts
LogsReal-time viewing, search by time/level/keyword, logrotate, GoAccess, Loki
FilesBrowse, edit, permissions, compress/extract, rsync transfer
UsersLinux users, sudo rules, SSH keys, SFTP chroot accounts
CronView, add, debug scheduled tasks + systemd timers
SecuritySSH hardening, kernel tuning, auditd, intrusion detection, backup
Multi-serverManage any number of servers; local workspace context for instant session resumption

Zero-Token-Waste Session Memory

The skill maintains two layers of context:

  • Server-side/etc/server-index.json — auto-generated by generate-index.sh, contains every deployed service, database, Docker container, SSL cert, user, open port, WAF status, and more.
  • Local workspace.server/snapshots/<server-id>.json — pulled via sync-context.sh. In any new AI session, the agent reads this file instantly and already knows your entire server environment without asking.

Supported Distros

DistroPackage ManagerNginx ConfigInit System
Ubuntu 20.04 / 22.04 / 24.04aptsites-availablesystemd
Debian 11 / 12aptsites-availablesystemd
CentOS Stream 8/9dnfconf.dsystemd
RHEL 8/9dnfconf.dsystemd
Rocky Linux / AlmaLinuxdnfconf.dsystemd
Fedoradnfconf.dsystemd
Alpine Linuxapkhttp.dOpenRC
Arch / Manjaropacmanconf.dsystemd

Installation

Prerequisites

  • macOS or Linux local machine
  • ssh and scp available in your terminal
  • jq installed locally: brew install jq (macOS) · apt-get install -y jq (Linux)

Option 1: Cursor (Recommended)

Personal skill (available in all your projects):

# Works for both first install and future updates — run anytime
git clone https://github.com/michael-ltm/linux-server-skill.git ~/.cursor/skills/linux-server-ops 2>/dev/null \
|| git -C ~/.cursor/skills/linux-server-ops pull origin main

Project skill (shared with your team via git):

mkdir -p .cursor/skills
git clone https://github.com/michael-ltm/linux-server-skill.git .cursor/skills/linux-server-ops 2>/dev/null \
|| git -C .cursor/skills/linux-server-ops pull origin main

Restart Cursor. The skill is automatically discovered — no configuration needed.

Option 2: Claude Code (claude.ai/code · Anthropic)

git clone https://github.com/michael-ltm/linux-server-skill.git ~/.claude/skills/linux-server-ops 2>/dev/null \
|| git -C ~/.claude/skills/linux-server-ops pull origin main

The agent reads skills from ~/.claude/skills/ automatically when you start a session.

Option 3: OpenClaw

git clone https://github.com/michael-ltm/linux-server-skill.git ~/.openclaw/skills/linux-server-ops 2>/dev/null \
|| git -C ~/.openclaw/skills/linux-server-ops pull origin main

Or configure the skill path in OpenClaw's settings panel to point to the cloned directory.

Option 4: Any AI Coding Assistant (Generic)

git clone https://github.com/michael-ltm/linux-server-skill.git /path/to/skills/linux-server-ops 2>/dev/null \
|| git -C /path/to/skills/linux-server-ops pull origin main

The main entry point is SKILL.md. The agent reads it first, then loads referenced guide files on demand.

How it works: git clone succeeds on first install. If the directory already exists it fails silently (2>/dev/null), then || triggers git pull to update instead. One command, works every time.


Quick Start

Step 1 — Add your first server

Run this in your project workspace (the directory you have open in Cursor/Claude Code):

bash ~/.cursor/skills/linux-server-ops/scripts/sync-context.sh --add

You'll be prompted for:

  • Server ID (e.g. prod-web)
  • Host IP or hostname
  • SSH port (default: 22)
  • SSH user (e.g. ubuntu)
  • Path to private key (e.g. ~/.ssh/my_key)

This creates .server/servers.json in your workspace.

Security: Add .server/servers.json to .gitignore — it contains your SSH connection info.

echo".server/servers.json">> .gitignore
echo".server/snapshots/">> .gitignore

Step 2 — Sync server state

bash ~/.cursor/skills/linux-server-ops/scripts/sync-context.sh

This connects to your server, runs a full scan, and saves the snapshot to .server/snapshots/prod-web.json.

Output example:

→ Syncing: prod-web (ubuntu@1.2.3.4:22)
✓ SSH connection successful
→ Scanning server (this may take ~10 seconds)...
✓ Snapshot saved: .server/snapshots/prod-web.json
Snapshot Summary: prod-web
Host: web-01 (1.2.3.4)
OS: Ubuntu 22.04
RAM: 8.0Gi Disk: 12G/100G (12%)
Websites: 2
Services: 3
Databases: 2 engines
SSL Certs: 2
Docker: 4 containers

Step 3 — Bootstrap your server (first time only)

Upload and run the init script on your server. This installs Nginx, Certbot, fail2ban, firewall, and all other dependencies:

# Upload scripts
scp -i ~/.ssh/my_key ~/.cursor/skills/linux-server-ops/scripts/check-system.sh ubuntu@1.2.3.4:/tmp/
scp -i ~/.ssh/my_key ~/.cursor/skills/linux-server-ops/scripts/generate-index.sh ubuntu@1.2.3.4:/tmp/
scp -i ~/.ssh/my_key ~/.cursor/skills/linux-server-ops/scripts/service-registry.sh ubuntu@1.2.3.4:/tmp/
# Run bootstrap
ssh -i ~/.ssh/my_key ubuntu@1.2.3.4 'sudo bash /tmp/check-system.sh'# Install management scripts on server
ssh -i ~/.ssh/my_key ubuntu@1.2.3.4 'sudo mkdir -p /opt/server-tools && sudo mv /tmp/generate-index.sh /tmp/service-registry.sh /opt/server-tools/ && sudo chmod +x /opt/server-tools/*.sh'

Step 4 — Start using it

Open a new Cursor/Claude Code session in your workspace. The AI agent will automatically read .server/snapshots/prod-web.json and instantly know your server environment.

Just ask naturally:

"Deploy my React app from ./dist to my server at blog.example.com with SSL"
"Set up a Node.js service on port 3000 with PM2"
"Show me all running services and their status"
"The API is returning 502 — what's wrong?"
"Create an SFTP user for my client to upload files to /var/www/mysite"
"Set up ModSecurity WAF with OWASP rules"
"Block this IP: 1.2.3.4"
"Show me the Nginx error logs from the last hour"
"Add a daily backup cron job"
"Create a MySQL database and user for my app"

Workspace File Structure

After setup, your workspace will contain:

your-project/
├── .server/
│ ├── servers.json ← SSH configs (add to .gitignore)
│ └── snapshots/
│ ├── prod-web.json ← Production server state
│ └── staging.json ← Staging server state
└── .gitignore ← Must include .server/servers.json

servers.json format

{
"default": "prod-web",
"servers": {
"prod-web": {
"label": "Production Web Server",
"host": "1.2.3.4",
"port": 22,
"user": "ubuntu",
"key_path": "~/.ssh/prod_key",
"tags": ["production", "web"],
"snapshot": ".server/snapshots/prod-web.json"
}
}
}

Managing multiple servers

# Add another server
bash ~/.cursor/skills/linux-server-ops/scripts/sync-context.sh --add
# List all configured servers
bash ~/.cursor/skills/linux-server-ops/scripts/sync-context.sh --list
# Sync all servers at once
bash ~/.cursor/skills/linux-server-ops/scripts/sync-context.sh --all
# Sync specific server
bash ~/.cursor/skills/linux-server-ops/scripts/sync-context.sh staging

Script Reference

Local scripts (run on your machine)

ScriptPurpose
scripts/sync-context.sh --addInteractively add a server to workspace context
scripts/sync-context.sh [id]Pull server state to local snapshot
scripts/sync-context.sh --allSync all configured servers
scripts/sync-context.sh --listList all configured servers
scripts/sync-context.sh --show [id]Print snapshot details

Server-side scripts (uploaded to /opt/server-tools/)

ScriptPurpose
check-system.shBootstrap: install all dependencies on a fresh server
generate-index.shScan server state and write /etc/server-index.json
generate-index.sh --printScan and print JSON only (used by sync-context.sh)
service-registry.sh listList all registered services
service-registry.sh healthHealth check all services + DB + Docker
service-registry.sh dbDatabase status (MySQL / PostgreSQL / Redis / MongoDB)
service-registry.sh dockerDocker containers + Compose projects
service-registry.sh cronAll scheduled jobs
service-registry.sh summaryFull server summary
service-registry.sh set <name> '{...}'Add/update a service entry
service-control.sh status [name]Show status of all services or one specific service
service-control.sh restart <name>Hard restart any service (auto-detects type)
service-control.sh reload <name>Graceful zero-downtime reload
service-control.sh start/stop <name>Start or stop a service
service-control.sh enable <name>Enable auto-start on boot
service-control.sh boot-checkVerify ALL services have auto-start configured
service-control.sh boot-fixEnable auto-start for all detected services
service-control.sh logs <name> [n]View last N log lines

Guide Reference

FileTopic
SKILL.mdMain entry point — all capabilities and quick-reference commands
distro-guide.mdUbuntu / Debian / CentOS / RHEL / Alpine / Arch differences
deploy-guide.mdFull deployment workflows: Static, Node.js, Java, Python, PHP, Docker, DB
waf-guide.mdModSecurity, OWASP CRS, rate limiting, IP management, DDoS mitigation
monitoring-guide.mdSystem metrics, alerting, Netdata, Uptime Kuma, watchdog
log-guide.mdLog viewing, search, rotation, GoAccess, Loki/Promtail
file-ops-guide.mdFile manager: browse, edit, permissions, compress, transfer
security-guide.mdSSH hardening, auditd, kernel tuning, intrusion detection, backups
user-management-guide.mdUsers, groups, sudo, SSH keys, SFTP chroot, session auditing

Security Notes

  • Never commit servers.json — it contains SSH connection details
  • The server-side index /etc/server-index.json is stored as chmod 600 (root-only)
  • All .env files deployed by this skill are set to chmod 600
  • SSH password auth is disabled during server hardening; key-only auth is enforced
  • SFTP users are chroot-jailed to their web directories

License

MIT — free to use, modify, and distribute.

About

AI agent skill for Linux server management — deploy websites, Node/Java/Python/PHP services, Docker, SSL, WAF, databases, monitoring, logs, users via SSH. Works with Cursor, Claude Code, OpenClaw.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages