本文介绍了为什么我可以ping服务器,但无法通过ssh连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我平安我的服务器,它响应:

 用户@本地:〜$平my.server
平my.server(111.111.111.11)的数据的56(84)个字节。
从my.server 64字节(111.111.111.11):icmp_req = 1 TTL = 42 =时间38.4毫秒
从my.server 64字节(111.111.111.11):icmp_req = 2 TTL = 42 =时间50.0毫秒
从my.server 64字节(111.111.111.11):icmp_req = 3 TTL = 42 =时间58.6毫秒
^ C
--- my.server ping统计---
传输三包,3所接收,0%丢包,时间2003ms
RTT最小/平均/最大/ MDEV = 38.419 / 49.037 / 58.637 / 8.287毫秒

但是当我尝试SSH(的东西,我一直做的,已经做了相同的连接上过去几个小时),它挂起:

 用户@本地:〜$ SSH my.server

speedtest.net说,我的连接具有1.5 Mbps的下载和0.4 Mbps的上传速度

在那里了SSH挂起理由吗?


在回答提出了建议结果

从@ nsfyn55

 用户@本地:〜$ telnetmy.server 22
尝试111.111.111.11 ...
连接到my.server
转义字符是'^]'。
SSH-2.0-OpenSSH_4.3
连接国外主机关闭。

这@vahid:

 用户@本地:〜$ NC -v -w 1 111.111.111.111 -z 22
NC:超时不能为负


解决方案

中国平安(ICMP协议)和SSH是两种不同的协议。


  1. 这可能是ssh服务没有运行或者没有安装


  2. 防火墙限制(本地像iptables的服务器,甚至sshd的配置锁定)或(外部防火墙保护进来的交通网络托管111.111.111.111)


首先检查,看是否SSH端口可达

  NC -v -w 1 111.111.111.111 -z 22

如果它成功,则直到限制解除或SSH启动SSH应该如果不是那么它永远不会工作沟通

When I ping my server, it responds:

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

but when I try to ssh (something that I always do, and have been doing for the past few hours on the same connection), it hangs:

user@localhost:~$ ssh my.server

speedtest.net says that my connection has 1.5 Mbps download and 0.4 Mbps upload speed

is there a reason that ssh hangs?


Results from suggestions provided in answers

from @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.

from @vahid:

user@localhost:~$ nc -v -w 1 111.111.111.111 -z 22
nc: timeout cannot be negative
解决方案

ping (ICMP protocol) and ssh are two different protocols.

  1. It could be that ssh service is not running or not installed

  2. firewall restriction (local to server like iptables or even sshd config lock down ) or (external firewall that protects incomming traffic to network hosting 111.111.111.111)

First check is to see if ssh port is up

nc -v -w 1 111.111.111.111 -z 22

if it succeeds then ssh should communicate if not then it will never work until restriction is lifted or ssh is started

这篇关于为什么我可以ping服务器,但无法通过ssh连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 07:44