Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
kochetkov-ma avatar

Brewtools:Ssh

  • 6 installs
  • 29 repo stars
  • Updated August 5, 2026
  • kochetkov-ma/claude-brewcode

Helps with ai & agent building tasks.

About

brewtools:ssh is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted development.

  • brewtools:ssh
  • AI & Agent Building
  • AI-coding skill

Brewtools:Ssh by the numbers

  • 6 all-time installs (skills.sh)
  • +1 installs in the week ending Aug 2, 2026 (Skillselion tracking)
  • Ranked #12,824 of 16,544 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Aug 6, 2026 (Skillselion catalog sync)
npx skills add https://github.com/kochetkov-ma/claude-brewcode --skill brewtoolsssh

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs6
repo stars29
Last updatedAugust 5, 2026
Repositorykochetkov-ma/claude-brewcode

What it does

Helps with ai & agent building tasks.

Files

SKILL.mdMarkdownGitHub ↗

SSH Server Management

Manage remote Linux servers — connect, configure, deploy, administer with safety gates and persistent config.

<instructions>

Robustness Rules (MANDATORY — all phases)

Fail-Fast

RuleApplies to
Every Bash call MUST end with `&& echo "OK ..." \\
On FAILED — stop phase, report error, do NOT retry same command blindlyALL phases
SSH commands MUST use -o ConnectTimeout=10 -o BatchMode=yesALL SSH calls
Max 2 retries per failed operation; after 2nd failure — report and stopALL phases
Non-zero script exit — read stderr, diagnose, fix root cause, retry ONCEScripts

Loop Protection

RuleLimit
Phase 2 (Connection Setup) — max 3 key attempts, then ask user3 keys
Phase 2 → Phase 5 round-trips — if sent back to Phase 2 more than once, stop and report1 re-entry
Phase 5 (Execute) — max 5 SSH commands per invocation; if more needed, delegate to ssh-admin agent via Task5 commands
update-agent mode — max 3 servers per run; process first 3 and report remaining3 servers
AskUserQuestion — max 3 questions per phase; summarize missing info in one combined question3 per phase

Timeouts

OperationTimeoutAction on timeout
SSH connection test10s (ConnectTimeout=10)Report "Server unreachable", stop
server-discover.sh30s (timeout 30 bash ...)Report partial results, continue
Any single SSH command60s (timeout 60 ssh ...)Kill, report "Command timed out", ask user
Entire skill invocation15 SSH calls total maxStop, report progress, suggest manual continuation

Fallback Strategy

If a script fails and cannot be fixed: 1. Report exact error: script name, exit code, stderr 2. Attempt same operation manually (inline Bash) — scripts are helpers, not gatekeepers 3. If manual fallback also fails — report both attempts, ask user 4. Never silently swallow errors or continue with stale/missing data

Failed scriptManual alternative
detect-mode.shParse $ARGUMENTS yourself — keyword matching is simple
ssh-env-check.shRun ls ~/.ssh/id_* 2>/dev/null, ssh-add -l, cat ~/.ssh/config
server-discover.shRun individual SSH commands: uname -a, docker version, df -h
claude-local-ops.shRead/write CLAUDE.local.md directly with Read/Edit tools

Error Reporting (MANDATORY)

On ANY failure — before stopping or asking user — output:

SCRIPT_ERROR: <script-name>
EXIT_CODE: <code>
STDERR: <error message>
PHASE: <current phase>
ACTION: <what was attempted>
FALLBACK: <what will be tried next OR "asking user">

---

Phase 0: Mode Detection (MANDATORY FIRST STEP)

EXECUTE using Bash tool:

bash "${CLAUDE_SKILL_DIR}/scripts/detect-mode.sh" "$ARGUMENTS"

Output format:

ARGS: [arguments received]
MODE: [detected mode]

Use the MODE value and GOTO that mode section below.

Keyword in argsMODE
setup, new server, add serversetup
connect to, ssh to, loginconnect
configure, config, hardenconfigure
update agent, refresh agent, refreshupdate-agent
(any other text)execute
(empty, no servers configured)setup
(empty, servers configured)execute (prompt user)

---

Phase 1: Environment & Config Check

Runs for ALL modes before branching.

EXECUTE using Bash tool:

bash "${CLAUDE_SKILL_DIR}/scripts/ssh-env-check.sh" && echo "OK env-check" || echo "FAILED env-check"
STOP if FAILED -- fix SSH environment before continuing.

Parse output key=value pairs. Note available keys and ssh-agent status.

EXECUTE using Bash tool:

bash "${CLAUDE_SKILL_DIR}/scripts/claude-local-ops.sh" list 2>/dev/null || echo "NO_SERVERS"
ConditionAction
NO_SERVERS AND mode=setupGOTO Phase 2: Connection Setup
NO_SERVERS AND mode=execute/connectGOTO Phase 2 (need server first)
1 server AND mode=connect/executeUse as default, GOTO Phase 5
Multiple servers AND mode=connect/executeAskUserQuestion: which server? Then GOTO Phase 5
mode=setup (servers exist)GOTO Phase 2 (adding new server)
mode=configureAskUserQuestion: which server? Then GOTO Phase 5
mode=update-agentGOTO Mode: update-agent

---

Phase 2: Connection Setup

Step 1: Gather Connection Info

Use AskUserQuestion:

header: "SSH Server Setup"
question: "Provide connection details for the new server."

Collect via follow-up questions if not in $ARGUMENTS:

  • Host (IP or hostname) -- REQUIRED
  • User (default: deploy) -- REQUIRED
  • Port (default: 22) -- optional
  • Server name (short alias, e.g., vps-main) -- REQUIRED

Step 2: Key Discovery & Auth

EXECUTE using Bash tool:

bash "${CLAUDE_SKILL_DIR}/scripts/ssh-env-check.sh" && echo "OK keys" || echo "FAILED keys"

Parse available keys. Try connection with each key (ed25519 first, then rsa, then ecdsa):

EXECUTE using Bash tool:

ssh-keyscan -p PORT HOST >> ~/.ssh/known_hosts 2>/dev/null && echo "OK keyscan" || echo "FAILED keyscan"

EXECUTE using Bash tool:

ssh -o BatchMode=yes -o ConnectTimeout=10 -p PORT USER@HOST echo "OK auth" 2>/dev/null || echo "FAILED auth"

Step 3: If Key Auth Fails

Use AskUserQuestion:

header: "SSH Authentication"
question: "Key authentication failed. Choose auth method:"
options:
  - label: "Password login (will set up key auth)"
    description: "Connect with password, then install SSH key"
  - label: "Specify key path"
    description: "Provide path to an existing private key"
  - label: "Cancel"
    description: "Abort server setup"

If password login:

1. Generate dedicated key:

EXECUTE using Bash tool:

ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_SERVERNAME -N "" -C "claude@SERVERNAME" && echo "OK keygen" || echo "FAILED keygen"

Replace SERVERNAME with the server name alias.

2. Instruct user to copy key manually:

Interactive command required. Run this in your terminal:
```
! ssh-copy-id -i ~/.ssh/id_ed25519_SERVERNAME.pub -p PORT USER@HOST
```
This requires password entry which Claude Code cannot do non-interactively.

3. After user confirms, verify:

EXECUTE using Bash tool:

ssh -o BatchMode=yes -o ConnectTimeout=10 -i ~/.ssh/id_ed25519_SERVERNAME -p PORT USER@HOST echo "OK key-auth" 2>/dev/null || echo "FAILED key-auth"
STOP if FAILED -- key auth must work before proceeding.

Step 4: SSH Config Entry

EXECUTE using Bash tool:

grep -q "^Host SERVERNAME$" ~/.ssh/config 2>/dev/null && echo "EXISTS" || echo "NEW"

If NEW, add config entry using Edit/Write to ~/.ssh/config:

Host SERVERNAME
    HostName HOST
    User USER
    Port PORT
    IdentityFile ~/.ssh/id_ed25519_SERVERNAME
    StrictHostKeyChecking accept-new

Step 5: Final Connection Test

EXECUTE using Bash tool:

ssh -o BatchMode=yes -o ConnectTimeout=10 SERVERNAME echo "OK connection" 2>/dev/null || echo "FAILED connection"
STOP if FAILED -- connection must work before discovery.

---

Phase 3: Server Discovery

EXECUTE using Bash tool:

bash "${CLAUDE_SKILL_DIR}/scripts/server-discover.sh" "USER@HOST" PORT && echo "OK discovery" || echo "FAILED discovery"

Replace USER@HOST and PORT with actual values (or SSH config alias).

Parse output key=value pairs. Key fields:

  • OS, KERNEL, ARCH
  • DOCKER_VERSION, DOCKER_COMPOSE
  • DISK_INFO (data disks, mount points)
  • RUNNING_CONTAINERS, SERVICES
  • CURRENT_USER, USER_GROUPS

---

Phase 4: Persist Config

Step 1: Update CLAUDE.local.md

EXECUTE using Bash tool:

bash "${CLAUDE_SKILL_DIR}/scripts/claude-local-ops.sh" add "SERVERNAME" "HOST" "USER" "PORT" "KEYPATH" && echo "OK add" || echo "FAILED add"

EXECUTE using Bash tool:

bash "${CLAUDE_SKILL_DIR}/scripts/claude-local-ops.sh" update "SERVERNAME" "OS_VALUE" "KERNEL_VALUE" "DOCKER_VALUE" "DISK_VALUE" "WORKDIR_VALUE" && echo "OK update" || echo "FAILED update"

Replace placeholders with discovered values from Phase 3.

Step 2: Gitignore

EXECUTE using Bash tool:

grep -q "CLAUDE.local.md" .gitignore 2>/dev/null && echo "EXISTS" || (echo "CLAUDE.local.md" >> .gitignore && echo "ADDED")

Step 3: Generate ssh-admin Agent

EXECUTE using Bash tool:

cat "${CLAUDE_SKILL_DIR}/templates/ssh-admin-agent.md.template"

Replace placeholders in template:

  • {{SERVER_INVENTORY}} -- server table from CLAUDE.local.md
  • {{SERVER_DETAILS}} -- discovered OS/Docker/disk info per server
  • {{LAST_UPDATED}} -- current ISO timestamp

Write result to .claude/agents/ssh-admin.md using Write tool.

Step 4: Default Server

If this is the first server, set as default automatically.

If multiple servers exist, use AskUserQuestion:

header: "Default Server"
question: "Set SERVERNAME as the default SSH server?"
options:
  - label: "Yes"
  - label: "No"

If yes: EXECUTE using Bash tool:

bash "${CLAUDE_SKILL_DIR}/scripts/claude-local-ops.sh" set-default "SERVERNAME" && echo "OK default" || echo "FAILED default"

---

Phase 5: Execute User Request

Step 1: Load Safety Rules

Read references/safety-rules.md from skill directory for command classification rules.

Step 2: Plan & Classify

Analyze $ARGUMENTS. Create execution plan:

StepCommand(s)ClassificationConfirmation
1...READ/CREATE/MODIFY/SERVICE/DELETE/PRIVILEGEfree/confirm

Step 3: Confirmation Gate

For MODIFY/SERVICE commands -- use AskUserQuestion:

header: "SSH Action Confirmation"
question: "About to execute on SERVER:\n\n[command list]\n\nProceed?"
options:
  - label: "Yes, execute"
  - label: "Cancel"

For DELETE/PRIVILEGE commands -- use AskUserQuestion with explicit warning:

header: "DESTRUCTIVE SSH Action"
question: "WARNING: About to execute DESTRUCTIVE commands on SERVER:\n\n[command list]\n\nThis cannot be undone. Proceed?"
options:
  - label: "Yes, I understand the risks"
  - label: "Cancel"

For READ/CREATE commands -- execute freely, no confirmation needed.

Step 4: Execute

For complex multi-step operations, delegate to ssh-admin agent via Task tool:

ParameterValue
subagent_typessh-admin
prompt[Detailed task description with server info, safety classification, and specific commands to run]

For simple single-command operations, execute directly:

EXECUTE using Bash tool:

ssh SERVERNAME "COMMAND" && echo "OK" || echo "FAILED"

Step 5: Docker Auth (if needed)

If task involves Docker registry operations, read references/docker-auth-flow.md for auth patterns.

Use AskUserQuestion for registry credentials -- NEVER hardcode tokens.

---

Phase 6: Session Report

FieldValue
ServerSERVERNAME (HOST)
Mode[detected mode]
Actions[list of actions performed]
Changes[list of changes made on server]
Statussuccess / partial / failed

After execution: if new info discovered, update CLAUDE.local.md; if server state changed significantly, update ssh-admin agent.

bash "${CLAUDE_SKILL_DIR}/scripts/claude-local-ops.sh" update "SERVERNAME" ...

---

Mode: update-agent

Re-discover all configured servers and refresh the ssh-admin agent.

Step 1: List Servers

EXECUTE using Bash tool:

bash "${CLAUDE_SKILL_DIR}/scripts/claude-local-ops.sh" list

Step 2: Re-discover Each Server

EXECUTE using Bash tool:

bash "${CLAUDE_SKILL_DIR}/scripts/server-discover.sh" "USER@HOST" PORT && echo "OK discovery" || echo "FAILED discovery"

Step 3: Update Config & Agent

Update CLAUDE.local.md with fresh data for each server. Regenerate .claude/agents/ssh-admin.md from template with updated inventory. Set {{LAST_UPDATED}} to current timestamp. Report what changed since last update.

</instructions>

---

Output Format

# SSH [MODE]

## Detection

| Field | Value |
|-------|-------|
| Arguments | `$ARGUMENTS` |
| Mode | `[detected mode]` |

## Environment

| Component | Status |
|-----------|--------|
| SSH keys | [types found] |
| ssh-agent | [running/stopped] |
| SSH config | [exists/missing] |
| Servers configured | [N] |

## Server: [NAME]

| Property | Value |
|----------|-------|
| Host | [IP/hostname] |
| OS | [distribution] |
| Docker | [version] |
| Status | [connected/failed] |

## Actions Taken

- [action 1]
- [action 2]

## Status

[success / partial / failed]

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.