SSH RemoteForward通知客户端失败

我正在使用SSH将远程计算机(客户端)上的端口转发到另一台计算机(服务器)( ~/.ssh/config

主机客户端:

 Hostname {ip} ... RemoteForward localhost:{port} localhost:{port} 

问题是,即使服务器上没有监听,客户端也可以成功连接到localhost:port 。 唯一的失败指示是服务器上的消息: connect_to localhost port {port}: failed.

有没有办法将这个错误转发给客户端,并终止连接?

如果sshd无法build立由您的LocalForward指定的连接,您将立即closures到本地端口的连接。 如果不这样做,你的sshd是行为不端的。

以下是我所遇到的情况:

1号航站楼:

 dennis@lightning:~$ ssh -L 1111:localhost:1112 camel Last login: Tue Jan 29 00:05:28 2013 from lightning.home.kaarsemaker.net [dkaarsemaker@camel ~]$ channel 3: open failed: connect failed: Connection refused channel 3: open failed: connect failed: Connection refused 

每当我尝试在terminal2中连接时,都会打印错误消息。

2号航站楼:

 dennis@lightning:~$ telnet localhost 1111 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Connection closed by foreign host. 

而且我看到我读错了,因为你使用RemoteForward。 虽然对我来说有类似的结果,但立即断开:

 dennis@lightning:~$ ssh -R 1111:localhost:1112 camel.ams6.corp.booking.com Last login: Sun Feb 3 11:43:07 2013 from lightning.home.kaarsemaker.net [dkaarsemaker@camel ~]$ telnet localhost 1111 Trying 127.0.0.1... connect_to localhost port 1112: failed. Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'. Connection closed by foreign host.