ssh-tool

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

SSH Tool

SSH 工具

Execute commands on remote servers via SSH. Supports key-based authentication, tunnels, and file transfers.
通过SSH在远程服务器上执行命令。支持基于密钥的认证、隧道和文件传输。

Setup

设置

Requires SSH access to remote servers. Uses system SSH client.
需要拥有远程服务器的SSH访问权限。使用系统SSH客户端。

Usage

使用方法

Execute a Command

执行命令

bash
{baseDir}/ssh-tool.js --host server.example.com --user ubuntu --command "ls -la"
bash
{baseDir}/ssh-tool.js --host server.example.com --user ubuntu --command "ls -la"

With Key File

使用密钥文件

bash
{baseDir}/ssh-tool.js --host server.example.com --user ubuntu --key /path/to/key --command "uptime"
bash
{baseDir}/ssh-tool.js --host server.example.com --user ubuntu --key /path/to/key --command "uptime"

With Password

使用密码

bash
{baseDir}/ssh-tool.js --host server.example.com --user ubuntu --password "secret" --command "df -h"
bash
{baseDir}/ssh-tool.js --host server.example.com --user ubuntu --password "secret" --command "df -h"

Interactive Shell

交互式Shell

bash
{baseDir}/ssh-tool.js --host server.example.com --user ubuntu --key /path/to/key --shell
bash
{baseDir}/ssh-tool.js --host server.example.com --user ubuntu --key /path/to/key --shell

Options

选项

OptionDescriptionRequired
--host
Remote hostname or IPYes
--user
SSH usernameYes
--command
Command to executeYes*
--key
Path to SSH private keyNo
--password
SSH passwordNo
--port
SSH port (default: 22)No
--shell
Start interactive shellNo
--timeout
Command timeout in secondsNo (default: 30)
选项描述是否必填
--host
远程主机名或IP
--user
SSH用户名
--command
要执行的命令是*
--key
SSH私钥路径
--password
SSH密码
--port
SSH端口(默认:22)
--shell
启动交互式Shell
--timeout
命令超时时间(秒)否(默认:30)

When to Use

使用场景

  • Running commands on remote servers
  • Deploying code to production
  • Checking server status
  • Remote administration tasks
  • 在远程服务器上运行命令
  • 将代码部署到生产环境
  • 检查服务器状态
  • 远程管理任务

Notes

注意事项

  • Key-based authentication is recommended for automation
  • The tool uses system SSH client with ControlMaster for connection reuse
  • Supports both password and key-based authentication
  • 自动化场景下推荐使用基于密钥的认证
  • 该工具使用系统SSH客户端并通过ControlMaster实现连接复用
  • 同时支持密码和基于密钥的认证