我正在尝试使用从我的办公室机器到我的家用机器的 ssh 隧道,并且在我尝试使用它时出现错误。
我正在做的是像这样启动一个 shell:
ssh -gL 12345:my.home.domain:22 my.home.domain
Run Code Online (Sandbox Code Playgroud)
这给了我一个合适的外壳,没问题。我通常做的是通过这台办公机器ssh到我的家用机器,如下所示:
ssh -p 12345 127.0.0.1
Run Code Online (Sandbox Code Playgroud)
这一直对我有用,直到上周我在我的家用机器上设置了一个新系统(从 Ubuntu 切换到 Debian)。现在我收到一个错误。我仍然可以打开我的初始 ssh 连接,但是当我尝试使用该隧道时,我(在办公室机器上)收到此错误:
ssh_exchange_identification: Connection closed by remote host
Run Code Online (Sandbox Code Playgroud)
此外,当这种情况发生时,我设置了隧道的开放外壳会向它吐出这条线:
channel 3: open failed: connect failed: Connection timed out
Run Code Online (Sandbox Code Playgroud)
在这一点上,我不知所措。如果需要更多信息,我很乐意发布。
============== 进一步=============
在进一步摆弄之后,我发现当我尝试在各个端口上 telnet 时,我从服务器(我的家用机器)得到了不同的响应。如果我尝试:
telnet my.home.domain 22
Run Code Online (Sandbox Code Playgroud)
我得到这个:
Trying <my ip address>...
Connected to <my domain>.
Escape character is '^]'.
SSH-2.0-OpenSSH_5.5p1 Debian-6+squeeze2
Run Code Online (Sandbox Code Playgroud)
这是我所期望的。在设置隧道之后,然后 telnet 到那个,我看到了这个响应:
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Run Code Online (Sandbox Code Playgroud)
============== 还有更进一步的 ==================
根据kbulgrien的建议,以下是带有 -v 选项的客户端机器的输出:
ssh -vp 24600 127.0.0.1 OpenSSH_5.9p1 Debian-5ubuntu1,OpenSSL 1.0.1 2012 年 3 月 14 日 debug1:读取配置数据 /etc/ssh/ssh_config debug1:/etc/ssh/ssh_config 第 19 行:为 * 应用选项 debug1:连接到 127.0.0.1 [127.0.0.1] 端口 24600。 debug1:连接建立。 debug1:身份文件/home/jacob/.ssh/id_rsa type -1 debug1:身份文件/home/jacob/.ssh/id_rsa-cert type -1 debug1:身份文件/home/jacob/.ssh/id_dsa 类型-1 debug1:身份文件/home/jacob/.ssh/id_dsa-cert type -1 debug1:身份文件/home/jacob/.ssh/id_ecdsa type -1 debug1:身份文件/home/jacob/.ssh/id_ecdsa-cert type -1 ssh_exchange_identification:连接被远程主机关闭
最近安装时发生了类似的情况。在这种情况下,/etc/hosts.deny 存在,并且没有明确拒绝访问的设置,因此情况看起来类似。有必要更改 /etc/hosts.allow 添加类似以下内容:
sshd: 192.168.127.0/255.255.255.128
Run Code Online (Sandbox Code Playgroud)
IP 详细信息需要根据您的需要进行调整,或者ALL
如果不担心允许来自任何地方的 ssh,则将其替换为。
进行更改后,停止并重新启动 sshd。
以下问题的赞成答案提供了更多示例。
这是其他人的证词,将错误消息与解决方案联系起来。
如何修复:ssh_exchange_identification:使用 SSH 登录时连接被远程主机关闭问题