Ubuntu – Connection timeout when trying to SSH

ftpsshUbuntu

The other day I tried to connect to my remote server via SSH as i always have. But now when I try to connect it just times out after about 60 seconds. I run

service ssh start

Which tells me that Job is already running: ssh. I then ran

$netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:993             0.0.0.0:*               LISTEN      1972/dovecot        
tcp        0      0 0.0.0.0:995             0.0.0.0:*               LISTEN      1972/dovecot        
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      2030/mysqld         
tcp        0      0 0.0.0.0:110             0.0.0.0:*               LISTEN      1972/dovecot        
tcp        0      0 0.0.0.0:143             0.0.0.0:*               LISTEN      1972/dovecot        
tcp        0      0 0.0.0.0:10000           0.0.0.0:*               LISTEN      2157/perl           
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      3028/sshd           
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      2273/master         
tcp6       0      0 :::80                   :::*                    LISTEN      2618/apache2        
tcp6       0      0 :::21                   :::*                    LISTEN      2291/proftpd: (acce 
tcp6       0      0 :::22                   :::*                    LISTEN      3028/sshd 

I am able to access subdomains on my site, and FTP, but don't have the ability to SSH or even ping remotely. Any thoughts?

Best Answer

Some ideas:

  • To exclude a problem at your end (not on the server), run ssh with the -v argument to see what is going on.
  • telnet <server-ip> 22 will tell you if your connection reaches the server. It should respond with something like SSH-2.0-OpenSSH....
  • Check the server's log files (e.g. /var/log/auth.log, /var/log/secure) for any sshd-related messages. You should see connection attempts from your remote IP address if the connection reaches the server.
  • If your connection cannot reach your server's ssh port, this could have different reasons:
    • Routing problem (in this case, connections to other ports should no go through, too.)
    • External firewall blocking the connection.
    • Local firewall (iptables) blocking the connection. Check with iptables -L if you have any rules installed.
    • If you have denyhosts or fail2ban installed, then your IP is maybe blacklisted. Check your /etc/hosts.deny and the related log file.