npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

agent-ssh

v1.0.3

Published

SSH remote management CLI - execute commands, upload/download files via SSH

Readme

agent-ssh

SSH 远程管理 CLI 工具,支持在远程服务器上执行命令和传输文件。可独立作为 CLI 使用,也可作为 MCP Server 运行。

安装

全局安装

npm install -g agent-ssh
agent-ssh --help

本地安装

npm install
npm run build
node dist/cli.js --help

本地 link(发布前)

npm link
agent-ssh --help

CLI 命令

| 命令 | 功能 | |------|------| | exec <command> | 远程执行命令 | | upload <local> <remote> | 上传文件 | | download <remote> <local> | 下载文件 | | upload-dir <local> <remote> | 上传目录 | | download-dir <remote> <local> | 下载目录 | | list-servers | 列出已配置的服务器 | | --mcp | 以 MCP Server 模式运行 |

使用示例

# 使用配置文件中的服务器
agent-ssh exec "df -h" -s production
agent-ssh upload ./file.txt /root/file.txt -s development
agent-ssh download /var/log/app.log ./logs/ -s production
agent-ssh list-servers

# 直接指定连接参数
agent-ssh exec "ls -la" -H 192.168.1.100 -u root -p password
agent-ssh upload ./deploy.sh /opt/deploy.sh -H 192.168.1.100 -u root --private-key ~/.ssh/id_rsa

# JSON 格式输出
agent-ssh exec "uname -a" -s production --json

配置文件

创建 .agent-ssh/config.json 在命令执行的目录下:

{
  "servers": {
    "production": {
      "host": "192.168.1.100",
      "port": 22,
      "username": "root",
      "password": "your_password",
      "timeout": 60000
    },
    "development": {
      "host": "192.168.1.50",
      "port": 2222,
      "username": "admin",
      "privateKey": "/path/to/id_rsa",
      "timeout": 30000
    }
  },
  "defaultServer": "development"
}

配置文件搜索顺序

  1. AGENTS_SSH_CLI_CONFIG 环境变量指定路径
  2. 当前目录下的 .agent-ssh/config.json
  3. 项目目录下的 ssh-cli.config.json
  4. 当前目录下的 ssh-cli.config.json
  5. 用户主目录下的 .ssh-cli-config.json

配置参数说明

| 参数 | 必填 | 默认值 | 说明 | |------|------|--------|------| | host | 是 | - | SSH 服务器地址 | | port | 否 | 22 | SSH 端口 | | username | 是 | - | 用户名 | | password | 否 | - | 密码(与 privateKey 二选一) | | privateKey | 否 | - | 私钥路径或内容(与 password 二选一) | | timeout | 否 | 30000 | 超时时间(毫秒) |

认证方式

支持两种认证方式,passwordprivateKey 二选一即可:

密码认证:

agent-ssh exec "ls" -H 192.168.1.100 -u root -p mypassword

私钥认证:

agent-ssh exec "ls" -H 192.168.1.100 -u root -k ~/.ssh/id_rsa

MCP Server 模式

保留完整的 MCP 协议兼容性,可作为 Agent 的 MCP Server 使用。

agent-ssh --mcp

可用 MCP 工具

| 工具 | 说明 | |------|------| | ssh_list_servers | 列出所有已配置的服务器 | | ssh_execute_command | 执行命令 | | ssh_upload_file | 上传文件 | | ssh_download_file | 下载文件 | | ssh_upload_directory | 上传目录 | | ssh_download_directory | 下载目录 |

MCP 客户端配置

{
  "mcpServers": {
    "agent-ssh": {
      "command": "agent-ssh",
      "args": ["--mcp"]
    }
  }
}