|
|
@@ -1,8 +1,32 @@
|
|
|
-# 1. 正向端口转发
|
|
|
-### 在远程服务器(10.192.72.11 )上启动监听8101端口的服务
|
|
|
+# 0. 程序,配置
|
|
|
```bash
|
|
|
-~/zhch/dots.ocrv/zhchllm_daemon.sh
|
|
|
+# 在本机(192.168.247.197)上启动
|
|
|
+./setup_remote_copilot.sh
|
|
|
+```
|
|
|
+### 远端主机(10.192.72.11)的vscode中配置--远程[SSH:10.192.72.11]
|
|
|
+```json
|
|
|
+{
|
|
|
+ "http.proxyStrictSSL": false,
|
|
|
+ "http.systemCertificates": false,
|
|
|
+ "Lingma.HttpProxySettings": "manual",
|
|
|
+ "Lingma.HttpProxyConfigurationURL": "http://172.16.40.16:7280",
|
|
|
+ "http.proxy": "http://localhost:7280",
|
|
|
+ "http.proxySupport": "on",
|
|
|
+ "github.copilot.enable": {
|
|
|
+ "*": true,
|
|
|
+ "yaml": true,
|
|
|
+ "plaintext": true,
|
|
|
+ "markdown": true
|
|
|
+ },
|
|
|
+ "github.copilot.advanced": {
|
|
|
+ "debug.overrideEngine": "codex",
|
|
|
+ "debug.useNodeFetcher": true
|
|
|
+ },
|
|
|
+ "http.proxyAuthorization": null
|
|
|
+}
|
|
|
```
|
|
|
+
|
|
|
+# 1. 正向端口转发
|
|
|
### 在mac本机(192.168.247.197)上运行
|
|
|
```
|
|
|
ssh -L 8082:localhost:8101 10.192.72.11
|
|
|
@@ -12,6 +36,8 @@ 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=30 -o ServerAliveCountMax=3 -L 8082:localhost:8101 -R 7280:localhost:7890 -N ubuntu@10.192.72.11
|
|
|
```
|
|
|
这个 SSH 命令用于建立隧道连接,让您可以从本地访问远程服务器上的服务,同时为远程服务器提供代理访问。这正好可以解决您 ngrok 连接问题。
|
|
|
|
|
|
@@ -32,45 +58,14 @@ ssh -o "ExitOnForwardFailure=yes" -o "ServerAliveInterval=60" -o "ServerAliveCo
|
|
|
- **`-R 7280:localhost:7890`**: 远程端口转发
|
|
|
- 将远程服务器的 7280 端口转发到本地的 7890 端口
|
|
|
- 远程服务器访问 `localhost:7280` 相当于访问您本地的 `localhost:7890`
|
|
|
-
|
|
|
-## 使用 VS Code 的替代方案
|
|
|
-
|
|
|
-您可以使用 VS Code 的内置端口转发功能来替代 ngrok:
|
|
|
-
|
|
|
-1. 首先连接到远程服务器:
|
|
|
-
|
|
|
-
|
|
|
-```json
|
|
|
-[
|
|
|
- {
|
|
|
- "type": "command",
|
|
|
- "details": {
|
|
|
- "key": "remote-ssh.connectToHost"
|
|
|
- }
|
|
|
- }
|
|
|
-]
|
|
|
+- **`-R 参数的完整格式`**
|
|
|
```
|
|
|
-然后转发端口:
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-在命令面板中显示
|
|
|
-
|
|
|
-VS Code 设置
|
|
|
-
|
|
|
-您可以配置以下设置来优化远程开发体验:
|
|
|
-
|
|
|
-**remote.SSH.connectTimeout** 设置连接超时时间:
|
|
|
-
|
|
|
-**remote.SSH.useLocalServer** 启用本地服务器模式以提高连接稳定性:
|
|
|
-
|
|
|
-**remote.forwardOnOpen** 控制自动端口转发:
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-在设置编辑器中显示
|
|
|
-
|
|
|
-样您就可以通过 VS Code 的内置功能访问远程服务器上的应用(如您的 Gradio 应用),而不需要依赖 ngrok。
|
|
|
+-R [bind_address:]port:host:hostport
|
|
|
+```
|
|
|
+ - bind_address: 远程主机上的监听地址(可选), 不指定时默认是localhost
|
|
|
+ - port: 远程主机上的监听端口
|
|
|
+ - host: 本机的目标地址
|
|
|
+ - hostport: 本机的目标端口
|
|
|
|
|
|
|
|
|
```
|
|
|
@@ -96,6 +91,7 @@ ssh -i /Users/zhch158/.ssh/id_dotsocr_tunnel \
|
|
|
- **`-i /Users/zhch158/.ssh/id_dotsocr_tunnel`**
|
|
|
- 使用专用的 SSH 私钥文件
|
|
|
- 这是您为 DotsOCR 隧道专门生成的密钥,确保独占访问
|
|
|
+ - 可以不指定,使用默认的 `~/.ssh/id_rsa` 或其他默认密钥
|
|
|
|
|
|
#### ⚙️ 连接选项 (`-o`)
|
|
|
- **`ExitOnForwardFailure=yes`**
|
|
|
@@ -217,6 +213,28 @@ curl http://localhost:7280/some-api
|
|
|
3. **安全控制**:通过中间代理层实现访问权限控制
|
|
|
4. **进程绑定**:只有特定进程才能使用代理服务
|
|
|
|
|
|
-这样既解决了您的网络代理需求,又确保了安全性!🛡️✨
|
|
|
|
|
|
-找到具有 1 个许可证类型的类似代码
|
|
|
+🔍 验证监听状态
|
|
|
+连接到远程主机后,可以检查端口监听状态:
|
|
|
+```bash
|
|
|
+# 检查监听端口
|
|
|
+netstat -tlnp | grep 7280
|
|
|
+# 或
|
|
|
+ss -tlnp | grep 7280
|
|
|
+
|
|
|
+# 应该看到类似输出:
|
|
|
+# 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监听
|
|
|
+```
|
|
|
+
|
|
|
+## 杀死主机上指定用户ubuntu的所有vscode进程
|
|
|
+```bash
|
|
|
+sudo pkill -u ubuntu -f vscode
|
|
|
+```
|
|
|
+
|
|
|
+🛡️ 安全建议
|
|
|
+默认使用 localhost:最安全,只有本机用户可访问
|
|
|
+避免使用 0.0.0.0:除非确实需要外部访问
|
|
|
+使用特定 IP:如果需要内网访问,指定具体的内网 IP
|
|
|
+监控访问日志:定期检查谁在使用代理服务
|