# ssh **Repository Path**: opsx-tools/ssh ## Basic Information - **Project Name**: ssh - **Description**: SSH远程命令行工具 - **Primary Language**: Go - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-13 - **Last Updated**: 2025-12-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # opsx-ssh 高性能 SSH/SFTP 远程工具 ## 特性 - 🚀 **高性能**: 连接池、连接复用、Keep-Alive - 🔐 **多种认证**: 密码、密钥、自动密钥发现 - 📤 **SFTP 支持**: 文件上传、下载(类似 scp) - 🔄 **批量操作**: 支持批量执行命令 - ⚡ **并发处理**: 高性能并发支持 - 🚇 **SSH 隧道代理**: 支持本地端口转发(-L)、远程端口转发(-R)、动态端口转发/SOCKS代理(-D) - 💻 **交互式 Shell**: 支持交互式登录远程服务器 - 🎯 **易于使用**: 简洁的 CLI 接口,兼容标准 SSH 使用习惯 ## 安装 ### 快速下载(推荐) 自动检测平台并下载最新版本: ```bash # 使用 wget wget "https://gitee.com/opsx-tools/ssh/releases/download/latest/opsx-ssh-$(uname -s)-$(uname -m).tar.gz" # 或使用 curl curl -L -o opsx-ssh-$(uname -s)-$(uname -m).tar.gz \ "https://gitee.com/opsx-tools/ssh/releases/download/latest/opsx-ssh-$(uname -s)-$(uname -m).tar.gz" ``` ### 手动安装 ```bash # Linux/macOS tar -xzf opsx-ssh-*.tar.gz chmod +x opsx-ssh sudo mv opsx-ssh /usr/local/bin/ # Windows # 解压 zip 文件后直接运行 ``` ## 编译 ```bash go build -o opsx-ssh main.go ``` ## 快速开始 ### SSH 命令执行 ```bash # 交互式登录(类似标准 ssh) opsx-ssh root@172.16.1.123 opsx-ssh root@172.16.1.123 -i ~/.ssh/id_rsa opsx-ssh root@172.16.1.123 -p # 提示输入密码 # 执行命令 opsx-ssh 172.16.1.123 "ls -la" -u root -i ~/.ssh/id_rsa # 执行脚本 opsx-ssh script 172.16.1.123 /path/to/script.sh -u root -i ~/.ssh/id_rsa # 批量执行 echo -e "172.16.1.123\n192.168.1.101" > hosts.txt opsx-ssh batch hosts.txt "uptime" -u root -i ~/.ssh/id_rsa -n 10 ``` ### SFTP 文件操作 ```bash # 上传文件(类似 scp put) opsx-ssh put /local/file.txt root@172.16.1.123:/remote/file.txt # 上传目录(递归) opsx-ssh put /local/dir root@172.16.1.123:/remote/dir -r # 下载文件(类似 scp get) opsx-ssh get root@172.16.1.123:/remote/file.txt /local/file.txt # 下载目录(递归) opsx-ssh get root@172.16.1.123:/remote/dir /local/dir -r ``` ### SSH 端口转发(隧道) ```bash # 本地端口转发 (-L) opsx-ssh forward local 8080:localhost:80 root@172.16.1.123 # 远程端口转发 (-R) opsx-ssh forward remote 8080:localhost:80 root@172.16.1.123 # 动态端口转发/SOCKS 代理 (-D) opsx-ssh forward dynamic 1080 root@172.16.1.123 ``` ## 命令参数 ### 全局参数 - `-u, --user`: SSH 用户名(默认: "root") - `-p, --password`: SSH 密码(-p密码 直接提供,-p"" 或 --password-prompt 提示输入) - `-i, --identity`: SSH 私钥文件路径 - `--passphrase`: 私钥密码 - `-P, --port`: SSH 端口(默认: 22) - `-t, --timeout`: 连接超时时间(秒)(默认: 30) - `--keepalive`: 保持连接活跃(默认: true) ### 批量操作参数 - `-n, --parallel`: 并发数(默认: 5) ### SFTP 参数 - `-r, --recursive`: 递归操作目录 ## 许可证 MIT License - 详见 [LICENSE](LICENSE) 文件