Main Site ↗

ssh

by benchflow-ai889173GitHub

Execute commands on remote servers via SSH, transfer files with SCP, and manage multiple hosts. Use when working with remote servers, deployments, system administration, log analysis, or any task requiring remote command execution. Supports SSH agent, key-based, and password authentication via environment variables, never exposing credentials.

Unlock Deep Analysis

Use AI to visualize the workflow and generate a realistic output preview for this skill.

Powered by Fastest LLM

Development
Compatible Agents
Claude Code
Claude Code
~/.claude/skills/
Codex CLI
Codex CLI
~/.codex/skills/
Gemini CLI
Gemini CLI
~/.gemini/skills/
O
OpenCode
~/.opencode/skills/
O
OpenClaw
~/.openclaw/skills/
GitHub Copilot
GitHub Copilot
~/.copilot/skills/
Cursor
Cursor
~/.cursor/skills/
W
Windsurf
~/.codeium/windsurf/skills/
C
Cline
~/.cline/skills/
R
Roo Code
~/.roo/skills/
K
Kiro
~/.kiro/skills/
J
Junie
~/.junie/skills/
A
Augment Code
~/.augment/skills/
W
Warp
~/.warp/skills/
G
Goose
~/.config/goose/skills/
SKILL.md

SSH Server Management

Quick Connect

使用 paramiko 进行 SSH 连接:

import paramiko

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('目标IP', username='用户名', password='密码')

# 执行命令
stdin, stdout, stderr = ssh.exec_command('你的命令')
print(stdout.read().decode())

ssh.close()

Parameters

  • host: 服务器 IP 地址
  • username: SSH 用户名
  • password: SSH 密码
  • command: 要执行的命令

Usage Examples

基本连接测试:

ssh.connect('10.0.3.120', username='root', password='7758258Cc')

执行单个命令:

stdin, stdout, stderr = ssh.exec_command('uptime')
print(stdout.read().decode())

执行多个命令:

commands = ['cd /var/log', 'ls -la', 'cat syslog | tail -20']
for cmd in commands:
    ssh.exec_command(cmd)

交互式会话:

shell = ssh.invoke_shell()
shell.send('apt update\n')
time.sleep(2)
print(shell.recv(4096).decode())

Best Practices

  • ✅ 使用 paramiko 是 Windows/Linux 通用的最可靠方案
  • ✅ 始终使用 paramiko.AutoAddPolicy() 自动处理主机密钥
  • ⚠️ Windows OpenSSH 不支持某些 OpenSSH 语法
  • ⚠️ sshpass 仅限 Linux
  • ⚠️ plink 语法与 OpenSSH 不兼容

Troubleshooting

连接超时: 检查 IP、用户名、密码是否正确 权限错误: 确认用户有执行权限 主机密钥拒绝: 使用 AutoAddPolicy() 或手动添加主机密钥

See Also

Source: https://github.com/benchflow-ai/SkillsBench#registry-terminal_bench_2.0-full_batch_reviewed-terminal_bench_2_0_qemu-alpine-ssh-environment-skills-ssh

Content curated from original sources, copyright belongs to authors

Grade B
-AI Score
Best Practices
Checking...
Try this Skill

User Rating

USER RATING

0UP
0DOWN
Loading files...

WORKS WITH

Claude Code
Claude
Codex CLI
Codex
Gemini CLI
Gemini
O
OpenCode
O
OpenClaw
GitHub Copilot
Copilot
Cursor
Cursor
W
Windsurf
C
Cline
R
Roo
K
Kiro
J
Junie
A
Augment
W
Warp
G
Goose