SSH 隧道未按预期工作

SSH 隧道未按预期工作

我正在尝试通过公共 IP 隧道连接到私有服务器的端口 80。我知道 apache 在端口 80 上运行,因为如果我通过 ssh 进入公共 IP,我就可以通过 lynx 顺利访问私有服务器。我使用的命令如下:

ssh <remote_public_id> -N -L 9080:<private_ip_of_other_server>:80

然后访问http://本地主机:9080说无法连接。我是从 OSX 执行此操作的。运行 ssh -version 时,如果出现问题,我会得到以下信息:

OpenSSH_5.2p1, OpenSSL 0.9.8l 5 Nov 2009

根据 Ernest 的要求,以下是一些调试。这是在我输入密码之后。出于安全目的,删除了 IP 地址。

debug3: packet_send2: adding 48 (len 63 padlen 17 extra_pad 64)
debug2: we sent a password packet, wait for reply
debug1: Authentication succeeded (password).
debug1: Local connections to LOCALHOST:9080 forwarded to remote address <private_ip>:80
debug3: channel_setup_fwd_listener: type 2 wildcard 0 addr NULL
debug1: Local forwarding listening on ::1 port 9080.
debug2: fd 4 setting O_NONBLOCK
debug3: fd 4 is O_NONBLOCK
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 9080.
debug2: fd 5 setting O_NONBLOCK
debug3: fd 5 is O_NONBLOCK
debug1: channel 1: new [port listener]
debug1: Requesting [email protected]
debug1: Entering interactive session.

然后当我发出请求时进行此调试:

debug1: channel 3: free: direct-tcpip: listening port 9080 for zmanda port 80, connect from ::1 port 64917, nchannels 5
debug3: channel 3: status: The following connections are open:
  #2 direct-tcpip: listening port 9080 for zmanda port 80, connect from ::1 port 64912 (t4 r0 i0/0 o0/0 fd 6/6 cfd -1)
  #3 direct-tcpip: listening port 9080 for zmanda port 80, connect from ::1 port 64917 (t4 r1 i3/0 o3/0 fd 7/7 cfd -1)
  #4 direct-tcpip: listening port 9080 for zmanda port 80, connect from ::1 port 64918 (t3 r-1 i0/0 o0/0 fd 8/8 cfd -1)

debug3: channel 3: close_fds r 7 w 7 e -1 c -1
debug2: channel 4: open confirm rwindow 2097152 rmax 32768
debug2: channel 4: rcvd eof
debug2: channel 4: output open -> drain
debug2: channel 4: obuf empty
debug2: channel 4: close_write
debug2: channel 4: output drain -> closed
debug2: channel 4: read<=0 rfd 8 len 0
debug2: channel 4: read failed
debug2: channel 4: close_read
debug2: channel 4: input open -> drain
debug2: channel 4: ibuf empty
debug2: channel 4: send eof
debug2: channel 4: input drain -> closed
debug2: channel 4: send close
debug3: channel 4: will not send data after close
debug2: channel 4: rcvd close
debug3: channel 4: will not send data after close
debug2: channel 4: is dead
debug2: channel 4: garbage collecting
debug1: channel 4: free: direct-tcpip: listening port 9080 for zmanda port 80, connect from ::1 port 64918, nchannels 4
debug3: channel 4: status: The following connections are open:
  #2 direct-tcpip: listening port 9080 for zmanda port 80, connect from ::1 port 64912 (t4 r0 i0/0 o0/0 fd 6/6 cfd -1)
  #4 direct-tcpip: listening port 9080 for zmanda port 80, connect from ::1 port 64918 (t4 r1 i3/0 o3/0 fd 8/8 cfd -1)

debug3: channel 4: close_fds r 8 w 8 e -1 c -1

答案1

因此,问题涉及几个方面。

  1. 该 Web 应用程序通过 SSL 运行,因此我必须使用端口 443,而不是 80
  2. 无论出于什么原因,您都无法将 443 转发到其他本地端口。所以我不得不转发到 443。

最终的命令如下:

sudo ssh gdboling@<public_ip> -N -L 443:<private_host>:443 

相关内容