所以这对我有用:
ssh -v -L 8080:remotewebserver:8080 me@jumphost
Run Code Online (Sandbox Code Playgroud)
如果我还想包含更多端口呢?
我不仅要转发8080,还要转发8443、8923和8181?
我需要为每个端口都建立一个新的连接吗?
Ale*_*ies 20
不,每个转发端口不需要一个ssh连接,只需添加更多-L语句:
ssh -L LPort1:RHOST1:RPORT1 -L LPORT2:RHOST2:RPORT2 me@ju.mp.ho.st
如果您像这样设置匹配部分,则可以ssh jump使用“别名”将其缩短为:jump~/.ssh/config
Host jump
User myUserName
Hostname ju.mp.ho.st
Port 2345
LocalForward 8080 remotewebserver:8080
LocalForward 8443 remotewebserver:8443
LocalForward 8923 remotewebserver:8923
LocalForward 8181 remotewebserver:8181
# Eliminates reconnection delay, and does not try to re-forward ports:
Host *
ControlMaster auto
ControlPath /tmp/%r@%h:%p
Run Code Online (Sandbox Code Playgroud)
我已经使用这种技术很多年了,肯定已经有 10 多个端口,但是当我需要转发更多端口时,我使用 Dynamic Socks Proxy support -D。