如何解决这个错误:“ssh_exchange_identification:连接被远程主机closures”

错误:

ssh_exchange_identification:由远程主机closures的连接

有很多提出的解决scheme,但似乎没有解决我的问题。

这是我想要完成的:

我有一个服务器(10.0.0.5)的SSH上。 服务器有以下用户及其shell:

passport , shell=/bin/false user1, shell=git-shell user2, shell=git-shell me, shell=bash 

sshd_config文件的末尾有以下条目:

 AllowTcpForwarding no Match User passport,user1,user2 AllowTcpForwarding true PermitOpen 10.0.0.5:8080 PermitOpen 10.0.0.5:22 

我也启用了公钥authentication。 目标是禁止所有来自SSH的tcp转发,并且只允许上述用户在两个端口上转发:

 - SSH - a web server 

在我的/etc/hosts.allow.deny文件中没有条目。

我在/home/passport/.ssh/authorized_keys设置了相应的authorized_keys file (只是ssh-rsa …)。

从Windows机器上,尝试SSH:

 ssh [email protected] -N -L 22:10.0.0.5:22 -L 8080:10.0.0.5:8080 

这工作正常,当“我尝试冲浪到http://127.0.0.1:8080 ”这意味着我的端口转发工作正常。

现在,我想尝试通过该隧道SSH并使用'user1':

 ssh -N [email protected] 

在这一刻,我得到:

ssh_exchange_identification:由远程主机closures的连接

而如果我只是从我的Windows机器直接SSH,我成功了:

 ssh -N [email protected] 

我不知道为什么它不起作用。

我检查/var/log/auth.log并观察:

 Feb 4 10:28:23 myhost sshd[2097]: debug1: server_input_channel_open: ctype direct-tcpip rchan 257 win 16384 max 16384 Feb 4 10:28:23 myhost sshd[2097]: debug1: server_request_direct_tcpip: originator 0.0.0.0 port 0, target 10.0.0.5 port 22 Feb 4 10:28:23 myhost sshd[2097]: Received request to connect to host 10.0.0.5 port 22, but the request was denied. Feb 4 10:28:23 myhost sshd[2097]: debug1: server_input_channel_open: failure direct-tcpip 

我尝试用-F刷新iptables,然后尝试重新启动sshd,但仍然出现连接closures错误。

  • 为什么我不能通过隧道ssh?

  • 我创build“护照”用户的原因是允许用户远程login到我的networking。 他们将能够使用Web服务器。

现在,如果他们想要使用GIT,他们将使用下面的例子:

 git clone ssh://[email protected]/repos/repo.git 

我正在运行Debian 6,Linux 2.6.32和OpenSSH 5.5p1

请告知如何解决我的问题。 我尝试了与我的问题相同标题列出的所有解决scheme,但无济于事。

你只能指定一个PermitOpen指令; 如果要允许多个转发,请在同一行中用空格分隔来指定它们:

 PermitOpen 10.0.0.5:8080 10.0.0.5:22 

看来OpenSSH应用了find的第一个指令。