
Ssh
- 267 installs
- 534 repo stars
- Updated June 29, 2026
- zhinkgit/embeddedskills
ssh is an agent skill that manages OpenSSH config aliases, remote commands, scp transfers, port forwarding, and jump hosts for servers and embedded boards
About
The ssh skill is a Claude Code–oriented procedural package for everyday OpenSSH work: maintaining a single source of truth in ~/.ssh/config, resolving Host aliases, executing remote commands, moving files with scp, and setting up local port forwards or jump hosts. It targets embedded and Linux lab setups—example configs reference dev boards and bastions—but any solo builder with a few VPS or Pi nodes gets the same benefit. Scripts under ssh_config.py cover list, find, show, and add flows, with add performing a config backup first. The skill explicitly forbids storing passwords or private keys in config comments and supports optional first-connect host-key acceptance for trusted devices. No extra Python dependencies are required beyond the standard library, aligning with agents that should run deterministic CLI helpers on Windows, macOS, or Linux with an OpenSSH client installed.
- List, find, show, and add Host entries in ~/.ssh/config with automatic backup on add
- Remote exec and scp upload/download via Host alias with structured JSON command results
- Local port forwarding and ProxyJump bastion patterns for internal dev targets
- Comment metadata fields: description, tags, and location on config blocks
- Python 3 stdlib scripts only—requires OpenSSH client (ssh, scp, ssh-keygen)
Ssh by the numbers
- 267 all-time installs (skills.sh)
- +24 installs in the week ending Jul 28, 2026 (Skillselion tracking)
- Ranked #354 of 1,435 DevOps & CI/CD skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/zhinkgit/embeddedskills --skill sshAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 267 |
|---|---|
| repo stars | ★ 534 |
| Last updated | June 29, 2026 |
| Repository | zhinkgit/embeddedskills ↗ |
What it does
Manage ~/.ssh/config aliases, run remote commands, transfer files, and port-forward to lab boards or servers without memorizing host strings.
Who is it for?
Best when you're doing embedded Linux, homelab, or small VPS fleets and want alias-driven SSH, scp, and tunnels from Claude Code without a separate inventory database.
Skip if: Pure local-only frontend work with no remote hosts, or teams that mandate a commercial bastion product instead of user-managed OpenSSH config files.
When should I use this skill?
You need SSH server or Linux dev-board operations: config Host aliases, remote commands, scp, local port forwarding, or jump hosts.
What you get
Host aliases stay documented in ~/.ssh/config while the agent runs list/find/show/add, remote commands, and file sync through repeatable Python wrappers.
- Updated ~/.ssh/config Host entries with backup on add
- Structured JSON from remote command runs
- Completed scp uploads or downloads
By the numbers
- Four primary ssh_config.py operations: list, find, show, and add with backup
Files
SSH Skill
定位
这是一个轻量 SSH 操作网关。它不维护独立服务器数据库,默认只读取和写入标准 OpenSSH 配置:
~/.ssh/config核心原则:
- 使用
Host别名标识服务器,不直接记忆 IP/密码。 - 优先密钥认证和 OpenSSH 原生命令。
- 通过本 skill 的
scripts/脚本执行 SSH、SCP、配置检查和隧道操作。 - 写入
~/.ssh/config前必须自动备份。 - 不鼓励密码落盘;如必须使用密码,优先让 OpenSSH 交互提示或由用户自行配置安全凭据。
何时触发
当用户提到以下任务时使用本 skill:
- SSH、远程服务器、服务器 IP/主机名、
user@host - 登录、执行远程命令、检查服务器状态
- 上传、下载、部署、迁移文件
- 跳板机、
ProxyJump、内网访问 - 隧道、端口转发、数据库连接
- 配置
~/.ssh/config、新增/查找服务器别名
不要用于本机 localhost、当前目录、本地文件操作或普通网络概念解释。
脚本入口
优先从当前 skill 目录调用脚本。脚本目录为:
scripts/命令示例均以当前 skill 目录为基准。
常用命令
ssh_exec.py、ssh_transfer.py、ssh_tunnel.py 均支持:
--accept-new-host-key
--known-hosts-file <临时known_hosts路径>首次连接已确认可信的新开发板时,可显式追加 --accept-new-host-key。测试时如不想写入全局 known_hosts,可追加 --known-hosts-file <临时known_hosts路径>。
列出服务器
python scripts/ssh_config.py list查找服务器
python scripts/ssh_config.py find <关键词>验证别名解析
python scripts/ssh_config.py show <别名>新增服务器
写入前脚本会自动备份 ~/.ssh/config:
python scripts/ssh_config.py add <别名> --host <IP或域名> --user <用户> --port 22 --key ~/.ssh/id_ed25519可选:
--description "说明"
--tags tag1,tag2
--location "位置"
--proxy-jump <跳板机别名>执行远程命令
python scripts/ssh_exec.py <别名> "命令" --timeout 30脚本输出 JSON,包含 success、exit_code、stdout、stderr。
上传文件
python scripts/ssh_transfer.py upload <别名> "<本地路径>" "<远程路径>"下载文件
python scripts/ssh_transfer.py download <别名> "<远程路径>" "<本地路径>"建立本地端口转发
python scripts/ssh_tunnel.py <别名> --local-port <本地端口> --remote-host 127.0.0.1 --remote-port <远程端口>隧道命令会前台运行。需要后台长期保持时,先向用户说明影响和停止方式。
配置格式
推荐配置:
# description: 开发板
# tags: embedded,linux
# location: lab
Host 1380-P904
HostName 192.168.137.76
User root
Port 22
IdentityFile ~/.ssh/id_ed25519跳板机:
Host bastion
HostName bastion.example.com
User root
IdentityFile ~/.ssh/id_ed25519
Host internal-dev
HostName 10.0.1.20
User root
IdentityFile ~/.ssh/id_ed25519
ProxyJump bastion允许保留注释元数据:
descriptiontagslocation
不要在配置中写入真实密码、Token、私钥内容或其他敏感信息。
操作规则
- 查询类任务可以直接执行。
- 新增或修改
~/.ssh/config前,脚本必须创建备份。 - 删除配置、覆盖远程文件、部署、批量执行、端口转发等有风险操作,先向用户确认。
- 不直接运行裸
ssh/scp,优先使用本 skill 的脚本;只有在脚本不可用或用户明确请求时,才说明原因并使用回退命令。 - 不修改 Git、系统服务、防火墙、远程生产环境配置,除非用户明确要求。
- 执行远程命令时优先只读检查;涉及重启、删除、覆盖、安装、升级时先确认。
- 输出给用户时说明目标别名、实际 HostName、执行命令、关键结果和失败原因。
故障排查
优先检查:
1. python scripts/ssh_config.py show <别名> 2. ssh -G <别名> 是否能解析 HostName/User/Port 3. 密钥文件是否存在,权限是否合适 4. ProxyJump 别名是否也在 ~/.ssh/config 5. 网络是否可达,端口是否开放 6. 首次连接是否需要显式追加 --accept-new-host-key
如果脚本失败,保留真实 stderr,不要吞掉错误。
ssh
Claude Code skill,用于 SSH 服务器与 Linux 开发板操作:OpenSSH 配置管理、远程命令、文件上传下载、跳板机和本地端口转发。
功能
- 读取、查询和新增
~/.ssh/config中的Host别名 - 通过 Host 别名执行远程命令,并返回结构化 JSON
- 使用
scp上传和下载文件 - 建立本地端口转发,支持访问远端服务
- 支持
ProxyJump跳板机配置 - 首次连接可信设备时,可显式接受新主机指纹
环境要求
- Python 3.x(仅标准库,无额外 Python 依赖)
- OpenSSH 客户端:
ssh、scp、ssh-keygen - 可选:已配置 SSH 密钥,推荐使用
IdentityFile
Windows 10/11 通常已内置 OpenSSH 客户端;如果命令不可用,可在“可选功能”中安装 OpenSSH Client。
配置
ssh skill 不维护独立服务器数据库,唯一服务器清单是标准 OpenSSH 配置:
~/.ssh/config推荐使用 Host 别名管理设备:
# description: Linux 开发板
# tags: embedded,linux,dev-board
# location: lab
Host 1380-P904
HostName 192.168.137.76
User root
Port 22
IdentityFile ~/.ssh/id_ed25519跳板机示例:
Host bastion
HostName bastion.example.com
User root
IdentityFile ~/.ssh/id_ed25519
Host internal-dev
HostName 10.0.1.20
User root
IdentityFile ~/.ssh/id_ed25519
ProxyJump bastion允许保留以下注释元数据:
| 字段 | 说明 |
|---|---|
description | 设备或服务器说明 |
tags | 逗号分隔的标签 |
location | 位置或环境 |
不要在 ~/.ssh/config 中写入真实密码、Token、私钥内容或其他敏感信息。
常用命令
命令示例均以当前 skill 目录为基准。
列出服务器
python scripts/ssh_config.py list查找服务器
python scripts/ssh_config.py find <关键词>验证别名解析
python scripts/ssh_config.py show <别名>新增服务器
写入前脚本会自动备份 ~/.ssh/config:
python scripts/ssh_config.py add <别名> --host <IP或域名> --user <用户> --port 22 --key ~/.ssh/id_ed25519常用可选参数:
--description "说明"
--tags tag1,tag2
--location "位置"
--proxy-jump <跳板机别名>执行远程命令
python scripts/ssh_exec.py <别名> "uname -a" --timeout 30脚本输出 JSON,包含 success、exit_code、stdout、stderr。
上传文件
python scripts/ssh_transfer.py upload <别名> "<本地路径>" "<远程路径>"下载文件
python scripts/ssh_transfer.py download <别名> "<远程路径>" "<本地路径>"建立本地端口转发
python scripts/ssh_tunnel.py <别名> --local-port <本地端口> --remote-host 127.0.0.1 --remote-port <远程端口>隧道命令会前台运行。需要后台长期保持时,先确认停止方式。
首次连接主机指纹
ssh_exec.py、ssh_transfer.py、ssh_tunnel.py 均支持:
--accept-new-host-key
--known-hosts-file <临时known_hosts路径>--accept-new-host-key:确认设备可信时,允许 OpenSSH 接受新的主机指纹。--known-hosts-file:指定known_hosts文件。调试时可使用临时文件,避免污染全局~/.ssh/known_hosts。
示例:
python scripts/ssh_exec.py 1380-P904 "echo SSH_OK && uname -m" --accept-new-host-key操作边界
- 查询类任务可以直接执行。
- 新增或修改
~/.ssh/config前,脚本必须创建备份。 - 删除配置、覆盖远程文件、部署、批量执行、端口转发等有风险操作,先确认。
- 执行远程命令时优先只读检查;涉及重启、删除、覆盖、安装、升级时先确认。
- 如果脚本失败,保留真实 stderr,不要吞掉错误。
故障排查
优先检查:
1. python scripts/ssh_config.py show <别名> 2. ssh -G <别名> 是否能解析 HostName/User/Port 3. ssh-keygen -F <HostName> 是否已有主机指纹 4. 密钥文件是否存在,权限是否合适 5. ProxyJump 别名是否也在 ~/.ssh/config 6. 网络是否可达,端口是否开放 7. 首次连接是否需要显式追加 --accept-new-host-key
#!/usr/bin/env python3
import argparse
import datetime as _dt
import json
import os
import shutil
import subprocess
import sys
from pathlib import Path
def ssh_config_path() -> Path:
return Path.home() / ".ssh" / "config"
def read_lines(path: Path) -> list[str]:
if not path.exists():
return []
return path.read_text(encoding="utf-8").splitlines()
def parse_hosts(lines: list[str]) -> list[dict]:
hosts: list[dict] = []
comments: list[str] = []
current: dict | None = None
def finish() -> None:
nonlocal current
if current:
hosts.append(current)
current = None
for line in lines:
stripped = line.strip()
if stripped.startswith("#") and current is None:
comments.append(line)
continue
if not stripped and current is None:
comments.append(line)
continue
if stripped.lower().startswith("host ") and not stripped.lower().startswith("host *"):
finish()
aliases = stripped.split(None, 1)[1].strip()
current = {
"alias": aliases,
"options": {},
"metadata": parse_metadata(comments),
"raw_comments": comments,
}
comments = []
continue
if current and (line.startswith(" ") or line.startswith("\t")) and stripped:
parts = stripped.split(None, 1)
if len(parts) == 2:
current["options"][parts[0].lower()] = parts[1]
continue
if current and not stripped:
finish()
comments = [line]
else:
comments = []
finish()
return hosts
def parse_metadata(comments: list[str]) -> dict:
metadata: dict = {}
for line in comments:
text = line.strip()
if not text.startswith("#"):
continue
text = text[1:].strip()
if ":" not in text:
continue
key, value = text.split(":", 1)
key = key.strip().lower()
value = value.strip()
if key in {"description", "tags", "location"}:
metadata[key] = value
return metadata
def backup_config(path: Path) -> Path | None:
if not path.exists():
return None
stamp = _dt.datetime.now().strftime("%Y%m%d-%H%M%S")
backup = path.with_name(f"{path.name}.bak-{stamp}")
shutil.copy2(path, backup)
return backup
def run_ssh_g(alias: str) -> dict:
proc = subprocess.run(
["ssh", "-G", alias],
text=True,
capture_output=True,
encoding="utf-8",
errors="replace",
)
if proc.returncode != 0:
return {"success": False, "stderr": proc.stderr.strip(), "config": {}}
config: dict[str, str] = {}
for line in proc.stdout.splitlines():
if " " not in line:
continue
key, value = line.split(" ", 1)
if key in {"hostname", "user", "port", "identityfile", "proxyjump"}:
config[key] = value
return {"success": True, "stderr": "", "config": config}
def cmd_list(_args: argparse.Namespace) -> int:
hosts = parse_hosts(read_lines(ssh_config_path()))
print(json.dumps({"success": True, "hosts": hosts}, ensure_ascii=False, indent=2))
return 0
def cmd_find(args: argparse.Namespace) -> int:
query = args.query.lower()
matches = []
for host in parse_hosts(read_lines(ssh_config_path())):
haystack = " ".join([
host.get("alias", ""),
json.dumps(host.get("metadata", {}), ensure_ascii=False),
json.dumps(host.get("options", {}), ensure_ascii=False),
]).lower()
if query in haystack:
matches.append(host)
print(json.dumps({"success": True, "hosts": matches}, ensure_ascii=False, indent=2))
return 0
def cmd_show(args: argparse.Namespace) -> int:
resolved = run_ssh_g(args.alias)
hosts = parse_hosts(read_lines(ssh_config_path()))
local = next((h for h in hosts if h["alias"] == args.alias), None)
result = {
"success": bool(resolved["success"] and local),
"alias": args.alias,
"defined": local is not None,
"metadata": local.get("metadata", {}) if local else {},
"options": local.get("options", {}) if local else {},
"resolved": resolved["config"],
"stderr": resolved["stderr"],
}
print(json.dumps(result, ensure_ascii=False, indent=2))
return 0 if result["success"] else 1
def cmd_add(args: argparse.Namespace) -> int:
path = ssh_config_path()
path.parent.mkdir(parents=True, exist_ok=True)
hosts = parse_hosts(read_lines(path))
if any(h["alias"] == args.alias for h in hosts):
print(json.dumps({
"success": False,
"error": f"Host alias already exists: {args.alias}",
}, ensure_ascii=False, indent=2), file=sys.stderr)
return 1
backup = backup_config(path)
tags = args.tags or ""
block: list[str] = []
if path.exists() and path.read_text(encoding="utf-8").strip():
block.append("")
if args.description:
block.append(f"# description: {args.description}")
if tags:
block.append(f"# tags: {tags}")
if args.location:
block.append(f"# location: {args.location}")
block.extend([
f"Host {args.alias}",
f" HostName {args.host}",
f" User {args.user}",
f" Port {args.port}",
])
if args.key:
block.append(f" IdentityFile {args.key}")
if args.proxy_jump:
block.append(f" ProxyJump {args.proxy_jump}")
with path.open("a", encoding="utf-8", newline="\n") as f:
f.write("\n".join(block))
f.write("\n")
print(json.dumps({
"success": True,
"alias": args.alias,
"config_path": str(path),
"backup_path": str(backup) if backup else None,
}, ensure_ascii=False, indent=2))
return 0
def main() -> int:
parser = argparse.ArgumentParser(description="Manage OpenSSH config hosts")
sub = parser.add_subparsers(dest="cmd", required=True)
p_list = sub.add_parser("list")
p_list.set_defaults(func=cmd_list)
p_find = sub.add_parser("find")
p_find.add_argument("query")
p_find.set_defaults(func=cmd_find)
p_show = sub.add_parser("show")
p_show.add_argument("alias")
p_show.set_defaults(func=cmd_show)
p_add = sub.add_parser("add")
p_add.add_argument("alias")
p_add.add_argument("--host", required=True)
p_add.add_argument("--user", required=True)
p_add.add_argument("--port", default="22")
p_add.add_argument("--key")
p_add.add_argument("--proxy-jump")
p_add.add_argument("--description")
p_add.add_argument("--tags")
p_add.add_argument("--location")
p_add.set_defaults(func=cmd_add)
args = parser.parse_args()
return args.func(args)
if __name__ == "__main__":
raise SystemExit(main())
#!/usr/bin/env python3
import argparse
import json
import subprocess
import sys
def add_host_key_options(cmd: list[str], args: argparse.Namespace) -> None:
if args.accept_new_host_key:
cmd.extend(["-o", "StrictHostKeyChecking=accept-new"])
if args.known_hosts_file:
cmd.extend(["-o", f"UserKnownHostsFile={args.known_hosts_file}"])
def main() -> int:
parser = argparse.ArgumentParser(description="Execute command through OpenSSH host alias")
parser.add_argument("alias")
parser.add_argument("command")
parser.add_argument("--timeout", type=int, default=30)
parser.add_argument("--accept-new-host-key", action="store_true")
parser.add_argument("--known-hosts-file")
args = parser.parse_args()
cmd = ["ssh"]
add_host_key_options(cmd, args)
cmd.extend([args.alias, args.command])
proc = subprocess.run(
cmd,
text=True,
capture_output=True,
encoding="utf-8",
errors="replace",
timeout=args.timeout,
)
result = {
"success": proc.returncode == 0,
"exit_code": proc.returncode,
"stdout": proc.stdout,
"stderr": proc.stderr,
}
print(json.dumps(result, ensure_ascii=False, indent=2))
return 0 if result["success"] else proc.returncode
if __name__ == "__main__":
try:
raise SystemExit(main())
except subprocess.TimeoutExpired as exc:
print(json.dumps({
"success": False,
"exit_code": -1,
"stdout": exc.stdout or "",
"stderr": f"timeout after {exc.timeout}s",
}, ensure_ascii=False, indent=2), file=sys.stderr)
raise SystemExit(124)
#!/usr/bin/env python3
import argparse
import json
import subprocess
import sys
def add_host_key_options(cmd: list[str], args: argparse.Namespace) -> None:
if args.accept_new_host_key:
cmd.extend(["-o", "StrictHostKeyChecking=accept-new"])
if args.known_hosts_file:
cmd.extend(["-o", f"UserKnownHostsFile={args.known_hosts_file}"])
def run(cmd: list[str], timeout: int) -> int:
proc = subprocess.run(
cmd,
text=True,
capture_output=True,
encoding="utf-8",
errors="replace",
timeout=timeout,
)
print(json.dumps({
"success": proc.returncode == 0,
"exit_code": proc.returncode,
"stdout": proc.stdout,
"stderr": proc.stderr,
"command": cmd,
}, ensure_ascii=False, indent=2))
return 0 if proc.returncode == 0 else proc.returncode
def main() -> int:
parser = argparse.ArgumentParser(description="Upload/download files through OpenSSH scp")
sub = parser.add_subparsers(dest="cmd", required=True)
p_upload = sub.add_parser("upload")
p_upload.add_argument("alias")
p_upload.add_argument("local_path")
p_upload.add_argument("remote_path")
p_upload.add_argument("--recursive", action="store_true")
p_upload.add_argument("--timeout", type=int, default=300)
p_upload.add_argument("--accept-new-host-key", action="store_true")
p_upload.add_argument("--known-hosts-file")
p_download = sub.add_parser("download")
p_download.add_argument("alias")
p_download.add_argument("remote_path")
p_download.add_argument("local_path")
p_download.add_argument("--recursive", action="store_true")
p_download.add_argument("--timeout", type=int, default=300)
p_download.add_argument("--accept-new-host-key", action="store_true")
p_download.add_argument("--known-hosts-file")
args = parser.parse_args()
cmd = ["scp"]
if args.recursive:
cmd.append("-r")
add_host_key_options(cmd, args)
if args.cmd == "upload":
cmd.extend([args.local_path, f"{args.alias}:{args.remote_path}"])
else:
cmd.extend([f"{args.alias}:{args.remote_path}", args.local_path])
return run(cmd, args.timeout)
if __name__ == "__main__":
try:
raise SystemExit(main())
except subprocess.TimeoutExpired as exc:
print(json.dumps({
"success": False,
"exit_code": -1,
"stdout": exc.stdout or "",
"stderr": f"timeout after {exc.timeout}s",
}, ensure_ascii=False, indent=2), file=sys.stderr)
raise SystemExit(124)
#!/usr/bin/env python3
import argparse
import subprocess
def add_host_key_options(cmd: list[str], args: argparse.Namespace) -> None:
if args.accept_new_host_key:
cmd.extend(["-o", "StrictHostKeyChecking=accept-new"])
if args.known_hosts_file:
cmd.extend(["-o", f"UserKnownHostsFile={args.known_hosts_file}"])
def main() -> int:
parser = argparse.ArgumentParser(description="Start foreground OpenSSH local port forwarding")
parser.add_argument("alias")
parser.add_argument("--local-port", required=True)
parser.add_argument("--remote-host", default="127.0.0.1")
parser.add_argument("--remote-port", required=True)
parser.add_argument("--accept-new-host-key", action="store_true")
parser.add_argument("--known-hosts-file")
args = parser.parse_args()
target = f"127.0.0.1:{args.local_port}:{args.remote_host}:{args.remote_port}"
cmd = ["ssh"]
add_host_key_options(cmd, args)
cmd.extend(["-N", "-L", target, args.alias])
return subprocess.call(cmd)
if __name__ == "__main__":
raise SystemExit(main())
Related skills
How it compares
Prefer this skill over ad-hoc shell snippets when you need structured JSON outputs and safe config edits with backup on every add.
FAQ
Who is ssh for?
Developers and hardware hackers who SSH into servers or boards regularly and want their agent to operate through named Host aliases instead of raw IPs.
When should I use ssh?
In Operate (infra) for maintenance and tunnels, in Build (integrations/backend) when flashing or testing on a remote board, and in Ship (launch) when pushing artifacts to a staging host—whenever OpenSSH is the transport.
Is ssh safe to install?
The skill edits your real SSH config and runs remote commands; review the Security Audits panel on this page, keep secrets out of config comments, and use IdentityFile keys rather than embedded credentials.