Two days ago I logged on server via ssh without any problems. Today I tried to do so 3 times with wrong login (simple mistake), it said there was a login error, so I checked and put in correct login. After that it just stopped and returned Connection timed out. Full output with -vvv argument:

OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
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 [] port 22.
debug1: connect to address port 22: Connection timed out
ssh: connect to host port 22: Connection timed out

What's more - I tried to go back to this wrong login but now it gave the same result as the correct one.

After hours of searching the solution (firewall etc.) I tried to set up the connection on Windows (Putty) as well as on Windows on different computer but the result was the same. It indicated that it wasn't a platform issue but the connection couldn't be set up because of network. As I thought - after connecting to my mobile hotspot I could set up ssh connection without any troubles. I asked a friend to log on his platform and network and he succeeded as well.

Do you have any idea what could have caused that?

  • What exactly indicated "that it wasn't a platform issue but the connection couldn't be set up because of network"? can you successfully ping 22? Does telnet 22 indicate a listening SSH server? (you can exit the latter using Ctrl-] then Ctrl-D) – steeldriver Jun 17 '17 at 15:34
  • The fact that I tried this on 2 different computers and 2 operating systems. Yes, I can ping it but telnet returned telnet: Unable to connect to remote host: Connection timed out – Fajeczny Jun 17 '17 at 16:01
  • 4
    My best guess is that the remote server has some kind of additional access control such as fail2ban that has (at least temporarily) banned your IP address from connecting – steeldriver Jun 17 '17 at 16:13
  • Maybe stupid question but your ouput looks exactly the same as in this question .. so are you sure the ssh server is running on the server? – derHugo Jun 17 '17 at 20:28
  • @steeldriver you were right, setting up new 3 hours session on server went without any problems :) thank you very much! – Fajeczny Jun 18 '17 at 9:41

@steeldriver hit the nail on the head: this is a (or similar) tool blocking (temporarily) your IP address.

It may be worth whitelisting your IP (though, if you're on a non-static connection method (eg from a home cable modem), this won't be effective; or if your machine is compromised, it could auto-login to remote devices and run nefarious content thereon):

Whitelisting is setup in the jail.conf file using a space separated list.

# "ignoreip" can be an IP address, a CIDR mask or a DNS host. Fail2ban will not                          
# ban a host which matches an address in this list. Several addresses can be                             
# defined using space separator.


ignoreip = 
# This will ignore connection coming from common private networks.
# Note that local connections can come from other than just, so
# this needs CIDR range too.
ignoreip =

You might also consider increasing the number of bad tries and/or cutting the length of the ban - see the fail2ban jail options documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.