- 向导:选/建主机(实时连通测试,可重试)→ 选/建隧道(端口智能默认)→ 立即前台运行 - install.sh 结尾 exec 进入向导(stdin 从 /dev/tty 读,兼容 curl|bash) - cli.py 抽出 run_foreground 供 start 与向导复用;修复向导新建隧道分支不可达
73 lines
2.7 KiB
Markdown
73 lines
2.7 KiB
Markdown
# SSH 隧道管理器
|
|
|
|
跨平台 SSH 本地端口转发工具:Windows 图形界面,Linux/macOS 命令行。
|
|
|
|
## 一键安装
|
|
|
|
**Windows**(图形界面,自动装好依赖、建快捷方式并启动):
|
|
|
|
```powershell
|
|
powershell -c "irm https://gitea.xbay.cc/leefer/ssh-e2e/raw/branch/main/install.ps1 | iex"
|
|
```
|
|
|
|
**Linux / macOS**(命令行版,安装到 `~/ssh-e2e`,提供 `ssh-tunnel` 命令):
|
|
|
|
```bash
|
|
curl -fsSL https://gitea.xbay.cc/leefer/ssh-e2e/raw/branch/main/install.sh | bash
|
|
```
|
|
|
|
安装完成会**自动进入中文配置向导**:按提示输入 SSH 地址、密码、远程端口等
|
|
(直接回车采用方括号里的默认值),填完隧道立即建立,Ctrl+C 断开。
|
|
|
|
## 典型场景
|
|
|
|
远程主机上有个服务只监听它自己的 `127.0.0.1:3000`,公网访问不到。
|
|
建一条隧道后,在本机打开 `http://127.0.0.1:3000` 即可直接访问该服务。
|
|
|
|
## 命令行用法(Linux/macOS,Windows 亦可 `python cli.py`)
|
|
|
|
```bash
|
|
ssh-tunnel # 交互向导:选已有主机/隧道或新建,建好直接运行
|
|
ssh-tunnel start web # 直接启动某条已配置的隧道(前台,Ctrl+C 断开)
|
|
ssh-tunnel list # 查看全部
|
|
ssh-tunnel test 我的服务器 # 测试主机认证
|
|
ssh-tunnel remove tunnel web
|
|
ssh-tunnel --help # 完整参数(host add / tunnel add 等)
|
|
```
|
|
|
|
## 图形界面(Windows)
|
|
|
|
双击仓库里的 **`启动.bat`**,或用上面的一键安装命令。
|
|
|
|
1. **主机**:添加 SSH 主机(密码/私钥认证,可「测试连接」)。
|
|
2. **隧道**:选主机,填远程地址(一般 `127.0.0.1`)、远程端口、本地端口,点「启动」。
|
|
3. 本机访问 `127.0.0.1:本地端口` 即等于远程服务;点「最小化/关闭」驻留系统托盘,隧道后台保持。
|
|
|
|
## 数据与安全
|
|
|
|
配置文件位置:Windows `%APPDATA%\SshTunnelManager\`、Linux `~/ssh-e2e/.config/`、
|
|
macOS `~/ssh-e2e/Library/`。密码与私钥口令:Windows 经 DPAPI 加密;Linux/macOS
|
|
在装有 keyring 时经 AES-GCM 加密(keyring 派生密钥),否则明文保存并在运行时提示。
|
|
主机公钥记录在配置目录 `known_hosts`,主机密钥变更时拒绝连接。
|
|
|
|
## 开发
|
|
|
|
```
|
|
main.py GUI 入口(pywebview + WebView2,仅 Windows)
|
|
cli.py 命令行入口(跨平台)
|
|
engine.py 隧道引擎:paramiko 转发、保活、自动重连
|
|
storage.py 配置存储:JSON + 平台加密
|
|
ui/ 图形界面(HTML/CSS/JS)
|
|
install.sh / install.ps1 一键安装脚本
|
|
test_sshd.py / test_e2e.py 本地自测(见下)
|
|
```
|
|
|
|
自测:
|
|
|
|
```bash
|
|
.venv/Scripts/python test_sshd.py # 窗口1:本地测试 SSH 服务端
|
|
.venv/Scripts/python test_e2e.py # 窗口2:端到端隧道验证
|
|
.venv/Scripts/python cli.py list # CLI 冒烟
|
|
```
|
|
|