- cli.py:无界面命令行(host/tunnel/list/test/start/remove),复用隧道引擎 - storage.py:配置目录跨平台(Win %APPDATA%,Linux ~/ssh-e2e/.config,macOS ~/ssh-e2e/Library), 非 Windows 经 keyring+AES-GCM 加密机密,无后端时明文并提示 - install.sh / install.ps1:经 gitea.xbay.cc 一键拉取安装 - 修复:Store 未创建配置目录的崩溃(CLI 路径)
70 lines
2.5 KiB
Markdown
70 lines
2.5 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
|
|
```
|
|
|
|
## 典型场景
|
|
|
|
远程主机上有个服务只监听它自己的 `127.0.0.1:3000`,公网访问不到。
|
|
建一条隧道后,在本机打开 `http://127.0.0.1:3000` 即可直接访问该服务。
|
|
|
|
## 命令行用法(Linux/macOS,Windows 亦可 `python cli.py`)
|
|
|
|
```bash
|
|
ssh-tunnel host add 我的服务器 root@1.2.3.4 # 添加主机(交互输入密码;私钥加 --key ~/.ssh/id_rsa)
|
|
ssh-tunnel test 我的服务器 # 测试连通与认证
|
|
ssh-tunnel tunnel add web --host 我的服务器 --lp 3000 --rp 3000
|
|
ssh-tunnel start web # 前台运行,Ctrl+C 断开
|
|
ssh-tunnel list # 查看全部
|
|
ssh-tunnel remove tunnel web
|
|
```
|
|
|
|
## 图形界面(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 冒烟
|
|
```
|
|
|