我可以通过多跳ssh访问一个linux服务器
ssh -L3880:localhost:3880 user@first-hop-server -t ssh -L3880:localhost:3880 user@end-server
这对通过ssh访问很好。 不过,我也想通过Web浏览器访问端服务器端口80上的Apache Web服务器。
我已经find解决scheme,而不是跳,但我不知道如何适应它。 我在MacOS机器上
编辑:如果我尝试Tero的build议,并激活SSH上的-v我看到或多或less:
debug1: Connection to port 3880 forwarding to localhost port 3880 requested. debug1: channel 3: new [direct-tcpip] debug1: Connection to port 3880 forwarding to localhost port 3880 requested. debug1: channel 2: new [direct-tcpip] channel 2: open failed: connect failed: Connection refused debug1: channel 2: free: direct-tcpip: listening port 3880 for localhost port 3880, connect from 127.0.0.1 port 38535, nchannels 3 debug1: Connection to port 3880 forwarding to localhost port 3880 requested. debug1: channel 4: new [direct-tcpip]
(它在不同的频道/端口上都被拒绝了)
由于一个Apache主机可以托pipe多个域,所以您需要确保您的浏览器在进行HTTP连接时发送Host标头,或者使用HTTPS发送相应的TLS标头。
为了达到这个目的,你需要编辑你的/etc/hosts文件,使其包含:
127.0.0.1 example.com
其中example.com是您想要到达的域。
之后,您可以创build一个如上所示的SSH隧道,并在您的浏览器中使用http://domain.com:port打开网站。
编辑:您需要最后转发到服务器的HTTP端口80或HTTPS端口443。
我使用端口80上的第二个隧道进行了修改
ssh -L3880:localhost:3880 user@first-hop-server -t ssh -L3880:localhost:80 user@end-server
所以我明白,本地端口:3880->第一跳:3880从第一跳另一个隧道端口3880到networking服务器端口80
并使用Terobuild议,我现在设法打开http://domain.com上的网站: 3880在/ etc / hosts中定义了127.0.0.1 domain.com