Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ssh server connect to host xxx port 22: Connection timed out on linux-ubuntu

Tags:

I am trying to connect to remote server via ssh but getting connection timeout.

I ran the following command

ssh [email protected]

and getting following result

ssh: connect to host [email protected] port 22: Connection timed out

but if try to connect on another remote server then I can login successfully.

So I think there is no problem in ssh and other person try to login with same login and password he can successfully login to server.

Please help me
Thanks.

like image 988
urjit on rails Avatar asked Aug 29 '12 06:08

urjit on rails


People also ask

How do I fix SSH port timed out connection 22?

Incorrect IP address or hostname – The error may be due to a simple typo. Before you check anything else, make sure you're trying to connect to the correct server. Incorrect SSH port number – By default, servers listen for SSH connections on port 22.

How do I fix SSH connection timeout?

The user will require to increase the SSH connection timeout to solve this problem; It can be done in two ways. One way is to set the keep-alive options in the server configuration file, and another way is to set the keep-alive option in the client configuration file.


2 Answers

Here are a couple of things that could be preventing you from connecting to your Linode instance:

  1. DNS problem: if the computer that you're using to connect to your remote server isn't resolving test.kameronderdehamer.nl properly then you won't be able to reach your host. Try to connect using the public IP address assigned to your Linode and see if it works (e.g. ssh [email protected]). If you can connect using the public IP but not using the hostname that would confirm that you're having some problem with domain name resolution.

  2. Network issues: there might be some network issues preventing you from establishing a connection to your server. For example, there may be a misconfigured router in the path between you and your host, or you may be experiencing packet loss. While this is not frequent, it has happenned to me several times with Linode and can be very annoying. It could be a good idea to check this just in case. You can have a look at Diagnosing network issues with MTR (from the Linode library).

like image 91
mfriedman Avatar answered Sep 19 '22 05:09

mfriedman


That error message means the server to which you are connecting does not reply to SSH connection attempts on port 22. There are three possible reasons for that:

  1. You're not running an SSH server on the machine. You'll need to install it to be able to ssh to it.

  2. You are running an SSH server on that machine, but on a different port. You need to figure out on which port it is running; say it's on port 1234, you then run ssh -p 1234 hostname.

  3. You are running an SSH server on that machine, and it does use the port on which you are trying to connect, but the machine has a firewall that does not allow you to connect to it. You'll need to figure out how to change the firewall, or maybe you need to ssh from a different host to be allowed in.

EDIT: as (correctly) pointed out in the comments, the third is certainly the case; the other two would result in the server sending a TCP "reset" package back upon the client's connection attempt, resulting in a "connection refused" error message, rather than the timeout you're getting. The other two might also be the case, but you need to fix the third first before you can move on.

like image 22
Akash S Avatar answered Sep 23 '22 05:09

Akash S