# ssh反向代理

通过下面方法,可以让不联网的主机,访问外部网络

将本地访问 `192.168.6.1:7890` 映射到远程主机的 `127.0.0.1:7890`

```sh
ssh -R 服务端:本地地址 用户名@服务端地址
```

```sh
ssh -R 127.0.0.1:7890:192.168.6.1:7890 root@xx.xx.xx.xx
```

验证代理转发成功

```sh
export http_proxy=127.0.0.1:7890
export https_proxy=127.0.0.1:7890
curl "https://ip.oxylabs.io/"
``````sh
curl --proxy "http://127.0.0.1:7890" "https://ip.oxylabs.io/"
```

看到返回的ip是本机出口ip,而不是远程主机的出口ip,即可说明转发成功

> ssh 果然是个强大的工具,哈哈哈~

## 参考链接
[用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/)
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9