我正在尝试从我的大学网络(代理)通过 SSH 连接到远程服务器。但是,每当我尝试通过 SSH 连接到主机时,我都会收到此错误
ssh_exchange_identification: Connection closed by remote host
Run Code Online (Sandbox Code Playgroud)
这是完整的描述:-
命令 :-
ssh -vvv root@serverIP -p serverPort
Run Code Online (Sandbox Code Playgroud)
输出 :-
OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /home/prashant/.ssh/config
debug1: /home/prashant/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Executing proxy command: exec /usr/bin/corkscrew 144.16.192.213 8080 serverIP serverPort
debug1: identity file /home/prashant/.ssh/id_rsa type -1
debug1: identity file /home/prashant/.ssh/id_rsa-cert type -1
debug1: identity file /home/prashant/.ssh/id_dsa type -1
debug1: identity file /home/prashant/.ssh/id_dsa-cert type -1
debug1: identity file /home/prashant/.ssh/id_ecdsa type -1
debug1: identity file /home/prashant/.ssh/id_ecdsa-cert type -1
debug1: permanently_drop_suid: 1000
ssh_exchange_identification: Connection closed by remote host
Run Code Online (Sandbox Code Playgroud)
我的配置文件包含这个
Host *
ProxyCommand /usr/bin/corkscrew 144.16.192.213 8080 %h %p
Run Code Online (Sandbox Code Playgroud)
谁能帮我解决这个问题?
谢谢 !
我不完全确定我的解释是正确的,但我认为这就是正在发生的事情。
连接被代理阻止。在浏览 HTTPS 站点的典型配置中,HTTP CONNECT(这是 corkscrew 用来反弹通过代理的东西)是必要的。代理无法过滤连接,因为它是加密的,它别无选择,只能让看起来像 SSL 连接的东西通过。(SSL和SSH其实是可以区分的,但是很多代理都懒得理会)但是,几乎所有的HTTPS站点都在默认端口(443)上,所以代理往往只会把连接反弹到443端口。我认为“连接被远程主机关闭” ” 是由于代理在看到您尝试退回到其他端口时断开连接。
如果可以,请更改 SSH 服务器的配置,使其侦听端口 443。“Proxy could not open connection to serverIP: Service Unavailable”表示代理愿意让您连接,但没有服务器侦听该端口港口。(无法保证一旦 SSH 协议开始发生,它就不会进行某种形式的流量分析并阻止您。)
你需要在目标机器上的根,使端口443上的服务器侦听如果没有运行HTTPS的服务器,它是那么容易添加行Port 443
中sshd_config
的文件并重新启动sshd
过程中(service ssh restart
,/etc/init.d/ssh restart
或一些这样的命令)。
您可以在同一个端口上同时运行 SSH 服务器和 HTTPS 服务器,因为客户端发送的第一个数据包足以判断请求的是哪个。您可以使用sslh多路复用器(另请参阅本指南)。