我试图从我的办公室机器使用SSH隧道到我的家用机器,并尝试使用它时得到一个错误。
我正在做的是像这样启动一个shell:
ssh -gL 12345:my.home.domain:22 my.home.domain
这是给我一个合适的壳,没有问题。 我通常做的是通过这台办公机器ssh到我的家用机器,像这样:
ssh -p 12345 127.0.0.1
直到上周,当我在家用机器上build立一个新的系统时(从Ubuntu切换到Debian),这一直对我有用。 现在我得到一个错误。 我仍然可以打开我的初始ssh连接,但是当我尝试使用这个隧道时,我得到(在办公室机器上)这个错误:
ssh_exchange_identification: Connection closed by remote host
另外,当发生这种情况时,我通过build立隧道的开放式shell获得这条线吐出来:
channel 3: open failed: connect failed: Connection timed out
在这一点上,我感到茫然。 如果需要更多的信息,我很乐意发布。
=============进一步说==============
在进一步的摆弄之后,我发现当我试图在不同的端口上进行telnet时,我得到了服务器(我的家用机器)的不同响应。 如果我尝试:
telnet my.home.domain 22
我回来了:
Trying <my ip address>... Connected to <my domain>. Escape character is '^]'. SSH-2.0-OpenSSH_5.5p1 Debian-6+squeeze2
这是我所期望的。 虽然build立隧道,然后telnet到,我看到这个回应:
Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'.
==============还有==================
根据kbulgrien的build议,这里是来自客户端机器的-v选项的输出:
ssh -vp 24600 127.0.0.1 OpenSSH_5.9p1 Debian-5ubuntu1,OpenSSL 1.0.1 2012年3月14日 debug1:读取configuration数据/ etc / ssh / ssh_config debug1:/ etc / ssh / ssh_config第19行:应用选项* debug1:连接到127.0.0.1 [127.0.0.1]端口24600。 debug1:build立连接。 debug1:身份文件/home/jacob/.ssh/id_rsatypes-1 debug1:身份文件/home/jacob/.ssh/id_rsa-certtypes-1 debug1:身份文件/home/jacob/.ssh/id_dsatypes-1 debug1:身份文件/home/jacob/.ssh/id_dsa-certtypes-1 debug1:身份文件/home/jacob/.ssh/id_ecdsatypes-1 debug1:身份文件/home/jacob/.ssh/id_ecdsa-certtypes-1 ssh_exchange_identification:由远程主机closures的连接
也许如果你有更多的ssh 10会话等待插入密码,你有这样的错误,我记得这是最近的SSH错误,如果你要validation这一点,使用下面的命令
for i in {1..15};do ssh -fNt [email protected] & >/dev/null ;done
像这样的事情发生在最近的安装。 在这种情况下,/etc/hosts.deny存在,并且没有明确拒绝访问的设置,所以情况看起来很相似。 有必要修改/etc/hosts.allow来添加如下内容:
sshd: 192.168.127.0/255.255.255.128
IP细节需要根据您的需要进行调整,或者如果不考虑允许从任何地方使用ssh,则ALLreplace为ALL 。
进行更改后,停止并重新启动sshd。
upvoted回答下面的问题提供了更多的例子。
SSH hosts.deny和hosts.allow
这是别人的见证,将错误信息与解决scheme联系起来。
如何解决:ssh_exchange_identification:使用SSHlogin时由远程主机问题closures的连接
我有同样的问题,最后通过更正/etc/network/interfaces来解决问题:
auto eth0 iface eth0 inet static
要么
auto eth0 iface eth0 inet dhcp
没有这个configuration我永远不会反向连接到我的SSH隧道。