对于一个项目,我可以通过另一台计算机(host_B)从我的计算机(host_A)访问计算机的localhost apache服务器(host_C),所有这些都使用ssh。
我已经成功通过host_B使用host_A与host_A连接:
ssh username_host_C@host_C
在我的.ssh/config
文件中:
Host host_C
ProxyCommand ssh username_host_B@host_B -W %h:%p
所以我尝试使用以下命令在地址http://localhost:8080的浏览器中执行ssh隧道访问host_C的本地网络服务器:
ssh -L 8080:host_C:80 username_host_B@host_B -N
当我连接到http://localhost:8080/时,它无法正常工作并在终端中说:
debug1: Connection to port 8080 forwarding to host_C port 80 requested.
debug1: channel 4: new [direct-tcpip]
答案 0 :(得分:0)
您正在连接到B并尝试从host_C:80 - host_C的公共地址上获取端口80。如果您的服务器仅在C上侦听localhost,那将无法工作 - 您需要使用ssh连接到C,并转发到localhost:80。像
这样的东西ssh -L 8080:localhost:80 username_host_C@host_C -N
应该这样做,假设你可以连接到host_C