ssh 反向代理

警告
本文最后更新于 2020-12-19,文中内容可能已过时。

服务器端

假设服务器[京东云]ip是:123.123.111.111

1
2
3
4
5
6
7
8
9
## 启动 firewalld 服务,添加端口 6666
fuser -k 6666/tcp

systemctl restart firewalld.service
firewall-cmd --zone=public --add-port=6666/tcp --permanent
systemctl stop firewalld.service

## 开启代理,通过外部访问 6666 转发到 6166(即内网服务器端口)
ssh -fNCL *:6666:localhost:6166 localhost

客户端

1
2
## 开启 6166,任何访问外网的端口会自动转发到 22,即 ssh 服务
ssh -4 -fNCR 6166:localhost:22 -o ServerAliveInterval=60 -o ServerAliveCountMax=10 -o ExitOnForwardFailure=True -p 22 root@123.123.111.111

相关内容

william 支付宝支付宝
william 微信微信
0%