Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can I ping a server but not connect via SSH? [closed]

Tags:

ssh

ping

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 

http://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 
like image 502
Abe Avatar asked Oct 03 '12 19:10

Abe


People also ask

Why is SSH connection closed?

SSH Port is ClosedIf the port is closed, the server refuses the connection. By default, SSH uses port 22. If you haven't made any configuration changes to the port, you can check if the server is listening for incoming requests. Find port 22 in the output and check whether its STATE is set to LISTEN.

Why is SSH not connecting?

Troubleshooting steps:Verify that the host IP address is correct. Verify the firewall rules, check the inbound rules allowed by the security group. Verify the port number allowed for ssh. Verify that the service is running properly.

Can ping but refused to connect?

This issue is typically caused by a problem with domain name server (DNS) resolution because the Internet service provider's DNS servers are unavailable or a problem with the security software (usually a firewall) running on the computer which is attempting to access the Internet.


1 Answers

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

like image 164
V H Avatar answered Oct 07 '22 11:10

V H