|
|
@@ -10,7 +10,7 @@
|
|
|
"http.systemCertificates": false,
|
|
|
"Lingma.HttpProxySettings": "manual",
|
|
|
"Lingma.HttpProxyConfigurationURL": "http://172.16.40.16:7280",
|
|
|
- "http.proxy": "http://localhost:7280",
|
|
|
+ "http.proxy": "http://localhost:7281",
|
|
|
"http.proxySupport": "on",
|
|
|
"github.copilot.enable": {
|
|
|
"*": true,
|
|
|
@@ -35,9 +35,9 @@ ssh -L 8082:localhost:8101 10.192.72.11
|
|
|
|
|
|
# 2. 双向端口转发
|
|
|
```
|
|
|
-ssh -o "ExitOnForwardFailure=yes" -o "ServerAliveInterval=60" -o "ServerAliveCountMax=3" -L 8082:localhost:8101 -R 7280:localhost:7890 ubuntu@10.192.72.11
|
|
|
+ssh -o "ExitOnForwardFailure=yes" -o "ServerAliveInterval=60" -o "ServerAliveCountMax=3" -L 8082:localhost:8101 -R 7281:localhost:7890 ubuntu@10.192.72.11
|
|
|
|
|
|
-ssh -o ExitOnForwardFailure=yes -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -L 8082:localhost:8101 -R 7280:localhost:7890 -N ubuntu@10.192.72.11
|
|
|
+ssh -o ExitOnForwardFailure=yes -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -L 8082:localhost:8101 -R 7281:localhost:7890 -N ubuntu@10.192.72.11
|
|
|
```
|
|
|
这个 SSH 命令用于建立隧道连接,让您可以从本地访问远程服务器上的服务,同时为远程服务器提供代理访问。这正好可以解决您 ngrok 连接问题。
|
|
|
|
|
|
@@ -55,9 +55,9 @@ ssh -o ExitOnForwardFailure=yes -o ServerAliveInterval=30 -o ServerAliveCountMa
|
|
|
- 将本地的 8082 端口转发到远程服务器的 8101 端口
|
|
|
- 访问 `localhost:8082` 相当于访问远程服务器的 `localhost:8101`
|
|
|
|
|
|
-- **`-R 7280:localhost:7890`**: 远程端口转发
|
|
|
- - 将远程服务器的 7280 端口转发到本地的 7890 端口
|
|
|
- - 远程服务器访问 `localhost:7280` 相当于访问您本地的 `localhost:7890`
|
|
|
+- **`-R 7281:localhost:7890`**: 远程端口转发
|
|
|
+ - 将远程服务器的 7281 端口转发到本地的 7890 端口
|
|
|
+ - 远程服务器访问 `localhost:7281` 相当于访问您本地的 `localhost:7890`
|
|
|
- **`-R 参数的完整格式`**
|
|
|
```
|
|
|
-R [bind_address:]port:host:hostport
|
|
|
@@ -69,7 +69,7 @@ ssh -o ExitOnForwardFailure=yes -o ServerAliveInterval=30 -o ServerAliveCountMa
|
|
|
|
|
|
|
|
|
```
|
|
|
-ssh -i /Users/zhch158/.ssh/id_dotsocr_tunnel -o ExitOnForwardFailure=yes -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -L 8082:localhost:8101 -R 7280:localhost:7281 -N ubuntu@10.192.72.11
|
|
|
+ssh -i /Users/zhch158/.ssh/id_dotsocr_tunnel -o ExitOnForwardFailure=yes -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -L 8082:localhost:8101 -R 7281:localhost:7281 -N ubuntu@10.192.72.11
|
|
|
```
|
|
|
这个 SSH 命令是您安全隧道方案的核心,让我详细解释每个参数的作用:
|
|
|
|
|
|
@@ -81,7 +81,7 @@ ssh -i /Users/zhch158/.ssh/id_dotsocr_tunnel \
|
|
|
-o ServerAliveInterval=30 \
|
|
|
-o ServerAliveCountMax=3 \
|
|
|
-L 8082:localhost:8101 \
|
|
|
- -R 7280:localhost:7281 \
|
|
|
+ -R 7281:localhost:7281 \
|
|
|
-N ubuntu@10.192.72.11
|
|
|
```
|
|
|
|
|
|
@@ -119,11 +119,11 @@ ssh -i /Users/zhch158/.ssh/id_dotsocr_tunnel \
|
|
|
|
|
|
##### 反向转发 (`-R`)
|
|
|
```
|
|
|
--R 7280:localhost:7281
|
|
|
+-R 7281:localhost:7281
|
|
|
```
|
|
|
- **作用**: 远程端口转发(关键的安全改进)
|
|
|
- **含义**:
|
|
|
- - 远程服务器的 `localhost:7280` → 您本机的 `localhost:7281`
|
|
|
+ - 远程服务器的 `localhost:7281` → 您本机的 `localhost:7281`
|
|
|
- 注意:这里转发到 7281 端口,而不是直接的 7890
|
|
|
|
|
|
#### 🚫 执行选项
|
|
|
@@ -144,7 +144,7 @@ ssh -i /Users/zhch158/.ssh/id_dotsocr_tunnel \
|
|
|
│ localhost:8082 ◄───────┼─────────┼──► localhost:8101 │
|
|
|
│ │ SSH │ │
|
|
|
│ 🔒 安全代理服务器 │ 隧道 │ 其他用户进程 │
|
|
|
-│ localhost:7281 ◄───────┼─────────┼──► localhost:7280 │
|
|
|
+│ localhost:7281 ◄───────┼─────────┼──► localhost:7281 │
|
|
|
│ │ │ │ │ │
|
|
|
│ ▼ │ │ ▼ │
|
|
|
│ 🎯 本地代理 │ │ ❌ 被拒绝 │
|
|
|
@@ -168,7 +168,7 @@ ssh -i /Users/zhch158/.ssh/id_dotsocr_tunnel \
|
|
|
{
|
|
|
"local_forward_port": 8082, # 对应 -L 8082:localhost:8101
|
|
|
"remote_service_port": 8101, # 远程 vLLM 服务端口
|
|
|
- "secure_proxy_port": 7281, # 对应 -R 7280:localhost:7281
|
|
|
+ "secure_proxy_port": 7281, # 对应 -R 7281:localhost:7281
|
|
|
"target_proxy_host": "127.0.0.1",
|
|
|
"target_proxy_port": 7890 # 最终的代理目标
|
|
|
}
|
|
|
@@ -176,7 +176,7 @@ ssh -i /Users/zhch158/.ssh/id_dotsocr_tunnel \
|
|
|
|
|
|
### 2. 安全流程
|
|
|
|
|
|
-1. **远程服务器上的进程**访问 `localhost:7280`
|
|
|
+1. **远程服务器上的进程**访问 `localhost:7281`
|
|
|
2. **SSH 隧道**将请求转发到您本机的 `localhost:7281`
|
|
|
3. **安全代理服务器**(secure_tunnel.py)在 7281 端口监听
|
|
|
4. **进程检查**:验证请求是否来自允许的进程(VS Code、Copilot)
|
|
|
@@ -187,10 +187,10 @@ ssh -i /Users/zhch158/.ssh/id_dotsocr_tunnel \
|
|
|
### 场景 1: 您使用 VS Code + Copilot
|
|
|
```bash
|
|
|
# 远程服务器上的 vLLM 进程请求代理
|
|
|
-curl http://localhost:7280/some-api
|
|
|
+curl http://localhost:7281/some-api
|
|
|
|
|
|
# 流程:
|
|
|
-# 1. 请求到达远程服务器的 7280 端口
|
|
|
+# 1. 请求到达远程服务器的 7281 端口
|
|
|
# 2. SSH 隧道转发到您本机的 7281 端口
|
|
|
# 3. 安全代理检测到 VS Code 进程运行 ✅
|
|
|
# 4. 转发请求到本机的 7890 端口(真实代理)
|
|
|
@@ -200,10 +200,10 @@ curl http://localhost:7280/some-api
|
|
|
### 场景 2: 其他用户尝试访问
|
|
|
```bash
|
|
|
# 其他用户在远程服务器执行
|
|
|
-curl http://localhost:7280/some-api
|
|
|
+curl http://localhost:7281/some-api
|
|
|
|
|
|
# 流程:
|
|
|
-# 1. 请求到达远程服务器的 7280 端口
|
|
|
+# 1. 请求到达远程服务器的 7281 端口
|
|
|
# 2. SSH 隧道转发到您本机的 7281 端口
|
|
|
# 3. 安全代理检测:没有 VS Code 进程 ❌
|
|
|
# 4. 返回 HTTP 403 Forbidden
|
|
|
@@ -224,14 +224,14 @@ curl http://localhost:7280/some-api
|
|
|
连接到远程主机后,可以检查端口监听状态:
|
|
|
```bash
|
|
|
# 检查监听端口
|
|
|
-netstat -tlnp | grep 7280
|
|
|
+netstat -tlnp | grep 7281
|
|
|
# 或
|
|
|
-ss -tlnp | grep 7280
|
|
|
+ss -tlnp | grep 7281
|
|
|
|
|
|
# 应该看到类似输出:
|
|
|
-# tcp 0 0 127.0.0.1:7280 0.0.0.0:* LISTEN # localhost 监听
|
|
|
-# tcp 0 0 0.0.0.0:7280 0.0.0.0:* LISTEN # 所有接口监听
|
|
|
-# tcp 0 0 10.192.72.11:7280 0.0.0.0:* LISTEN # 特定IP监听
|
|
|
+# tcp 0 0 127.0.0.1:7281 0.0.0.0:* LISTEN # localhost 监听
|
|
|
+# tcp 0 0 0.0.0.0:7281 0.0.0.0:* LISTEN # 所有接口监听
|
|
|
+# tcp 0 0 10.192.72.11:7281 0.0.0.0:* LISTEN # 特定IP监听
|
|
|
```
|
|
|
|
|
|
## 杀死主机上指定用户ubuntu的所有vscode进程
|