Linux SSH 连接被远程主机关闭

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14802645/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 18:59:16  来源:igfitidea点击:

SSH Connection closed by remote host

linuxubuntussh

提问by Petr P?ikryl

I have problem to connect with SSH to remote host but only on my home network (provider). If I am at another network (my friend in same city - different provider) the connection works perfect. Ping to the server (at my home) works. Also this problem I have only with this server. If I try connect to other host from my home network, it works. What should I do?

我在使用 SSH 连接到远程主机时遇到问题,但仅限于我的家庭网络(提供商)。如果我在另一个网络(我在同一城市的朋友 - 不同的提供商),则连接工作正常。Ping 到服务器(在我家)有效。我也只有这台服务器有这个问题。如果我尝试从我的家庭网络连接到其他主机,它就可以工作。我该怎么办?

nich@ubuntu:/etc$ ssh -vvv [email protected]
OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to www.sci.muni.cz [147.251.24.3] port 22.
debug1: Connection established.
debug1: identity file /home/nich/.ssh/id_rsa type -1
debug1: identity file /home/nich/.ssh/id_rsa-cert type -1
debug1: identity file /home/nich/.ssh/id_dsa type -1
debug1: identity file /home/nich/.ssh/id_dsa-cert type -1
debug1: identity file /home/nich/.ssh/id_ecdsa type -1
debug1: identity file /home/nich/.ssh/id_ecdsa-cert type -1
ssh_exchange_identification: Connection closed by remote host

nich@ubuntu:/etc$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.2 LTS
Release:        12.04
Codename:       precise

采纳答案by cnicutar

Here's how you can attempt to create a tunnel.

以下是您可以尝试创建隧道的方法。

  • intermediaryis a machine you trust to do the forwarding for you
  • remoteis the machine you're trying to get to

    ssh -N -L 20000:remote:22 user@intermediary
    
  • intermediary是您信任的机器,可以为您进行转发
  • remote是你想要到达的机器

    ssh -N -L 20000:remote:22 user@intermediary
    

Once you do this your local machine will listen on port 20000. When you connect with ssh to this port, on your host, the connection will be forwarded over the tunnel to intermediarywho will in turn forward it to remote.

执行此操作后,您的本地计算机将侦听端口 20000。当您使用 ssh 连接到此端口时,在您的主机上,连接将通过隧道转发给intermediary谁,然后将其转发给remote