Closed. This question is off-topic。它当前不接受答案。












想改善这个问题吗? Update the question,所以它是用于堆栈溢出的on-topic

已关闭8年。



Improve this question




当我ping服务器时,它会响应:
user@localhost:~$ ping my.server
PING my.server (111.111.111.11) 56(84) bytes of data.
64 bytes from my.server (111.111.111.11): icmp_req=1 ttl=42 time=38.4 ms
64 bytes from my.server (111.111.111.11): icmp_req=2 ttl=42 time=50.0 ms
64 bytes from my.server (111.111.111.11): icmp_req=3 ttl=42 time=58.6 ms
^C
--- my.server ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 38.419/49.037/58.637/8.287 ms

但是当我尝试ssh(我经常做的事情,并且在同一连接上已经做了几个小时了)时,它挂起了:
user@localhost:~$ ssh my.server

http://speedtest.net说我的连接下载速度为1.5 Mbps,上传速度为0.4 Mbps。

ssh挂起是有原因吗?

答案中提供建议的结果

来自@ nsfyn55
user@localhost:~$ telnetmy.server 22
Trying 111.111.111.11...
Connected to my.server
Escape character is '^]'.
SSH-2.0-OpenSSH_4.3
Connection closed by foreign host.

来自@vahid:
user@localhost:~$ nc -v -w 1 111.111.111.111 -z 22
nc: timeout cannot be negative

最佳答案

ping(ICMP协议(protocol))和ssh是两个不同的协议(protocol)。

  • 可能是ssh服务未运行或未安装
  • 防火墙限制(本地限制在服务器上,如iptables甚至sshd config锁定)或(保护向网络托管111.111.111.111传入通信的外部防火墙)

  • 首先检查一下ssh端口是否已启动
    nc -v -w 1 111.111.111.111 -z 22
    

    如果成功,则ssh应该通信,否则它将永远无法工作,直到解除限制或启动ssh

    关于ssh - 为什么可以ping服务器但不能通过SSH连接? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12715233/

    10-14 17:20
    查看更多