问题:我使用类似ssh -L 8080:localhost:8080 100.88.2.98 做端口映射的时候,然后在本地访问的时候总是有类似这样的输出:channel 4: open failed: connect failed: Connection refused
然后我换成 tunnel 总是有nodename nor servname provided, or not known 这样的提示。
不知道是什么原因导致的。
100.88.2.98 的 /etc/hosts
::1 localhost localhost.
127.0.0.1 localhost localhost.
的话,会优先用ipv6地址。
你应该
ssh -L 8080:127.0.0.1:8080 100.88.2.98
这个是加了命令的提示
debug2: fd 10 setting TCP_NODELAY
debug3: fd 10 is O_NONBLOCK
debug3: fd 10 is O_NONBLOCK
debug1: channel 3: new [direct-tcpip]
debug3: send packet: type 90
debug1: Connection to port 9200 forwarding to 127.0.0.1 port 9200 requested.
debug2: fd 11 setting TCP_NODELAY
debug3: fd 11 is O_NONBLOCK
debug3: fd 11 is O_NONBLOCK
debug1: channel 4: new [direct-tcpip]
debug3: send packet: type 90
debug3: receive packet: type 92
channel 3: open failed: connect failed: Connection refused
debug3: receive packet: type 92
channel 4: open failed: connect failed: Connection refused
debug2: channel 3: zombie
debug2: channel 3: garbage collecting
debug1: channel 3: free: direct-tcpip: listening port 9200 for 127.0.0.1 port 9200, connect from 127.0.0.1 port 52798 to 127.0.0.1 port 9200, nchannels 5
debug3: channel 3: status: The following connections are open:
#2 client-session (t4 r0 i0/0 o0/0 fd 7/8 cc -1)
debug2: channel 4: zombie
debug2: channel 4: garbage collecting
debug1: channel 4: free: direct-tcpip: listening port 9200 for 127.0.0.1 port 9200, connect from 127.0.0.1 port 52799 to 127.0.0.1 port 9200, nchannels 4
debug3: channel 4: status: The following connections are open:
#2 client-session (t4 r0 i0/0 o0/0 fd 7/8 cc -1)
debug1: Connection to port 9200 forwarding to 127.0.0.1 port 9200 requested.
debug2: fd 10 setting TCP_NODELAY
debug3: fd 10 is O_NONBLOCK
debug3: fd 10 is O_NONBLOCK
debug1: channel 3: new [direct-tcpip]
debug3: send packet: type 90
debug3: receive packet: type 92
channel 3: open failed: connect failed: Connection refused
debug2: channel 3: zombie
debug2: channel 3: garbage collecting
debug1: channel 3: free: direct-tcpip: listening port 9200 for 127.0.0.1 port 9200, connect from 127.0.0.1 port 52800 to 127.0.0.1 port 9200, nchannels 4
debug3: channel 3: status: The following connections are open:
#2 client-session (t4 r0 i0/0 o0/0 fd 7/8 cc -1)
我试过了,还是一样,而且我确认100.88.2.98的服务器没有 /etc/hosts . 没有相关的localhost 的设置。还会存在其他情况导致该问题吗?
ssh执行时加 -vvv ,看看有什么提示信息。