Blame
05f737 | Qwas | 2024-06-08 16:19:15 | 1 | # ssh反向代理 |
2 | ||||
3 | 通过下面方法,可以让不联网的主机,访问外部网络 |
|||
4 | ||||
5 | 将本地访问 `192.168.6.1:7890` 映射到远程主机的 `127.0.0.1:7890` |
|||
6 | ||||
7 | ```sh |
|||
8 | ssh -R 服务端:本地地址 用户名@服务端地址 |
|||
9 | ``` |
|||
10 | ||||
11 | ```sh |
|||
12 | ssh -R 127.0.0.1:7890:192.168.6.1:7890 root@xx.xx.xx.xx |
|||
13 | ``` |
|||
14 | ||||
15 | 验证代理转发成功 |
|||
16 | ||||
17 | ```sh |
|||
18 | export http_proxy=127.0.0.1:7890 |
|||
19 | export https_proxy=127.0.0.1:7890 |
|||
20 | curl "https://ip.oxylabs.io/" |
|||
21 | ``` |
|||
22 | ||||
23 | 或 |
|||
24 | ||||
25 | ```sh |
|||
26 | curl --proxy "http://127.0.0.1:7890" "https://ip.oxylabs.io/" |
|||
27 | ``` |
|||
28 | ||||
29 | 看到返回的ip是本机出口ip,而不是远程主机的出口ip,即可说明转发成功 |
|||
30 | ||||
31 | > ssh 果然是个强大的工具,哈哈哈~ |
|||
1a2934 | Qwas | 2024-06-08 16:25:20 | 32 | |
33 | ## 参考链接 |
|||
34 | [用ssh反向代理让不联网服务器上网](https://www.zhang-hb.com/2022/02/02/%E7%94%A8ssh%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86%E8%AE%A9%E4%B8%8D%E8%81%94%E7%BD%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8A%E7%BD%91/) |