今天为了将本地服务进行内网穿透供外网使用,试了ssh -R,但ss结果看到的只是绑定了127.0.0.1的接口,即使指定了0.0.0.0前缀也不行,查了下,是要在/etc/ssh/sshd_config的配置里把GatewayPorts设置为yes

1
2
3
4
5
6
7
8
9
10
11
# GatewayPorts no 的情况
local$ ssh -R 0.0.0.0:2080:localhost:8080 vps
vps$ ss -ltn
# State Local Address:Port
# LISTEN 127.0.0.1:2080

# GatewayPorts yes
local$ ssh -R 0.0.0.0:2080:localhost:8080 vps
vps$ ss -ltn
# State Local Address:Port
# LISTEN 0.0.0.0:2080