Linux – SSH Connection timed out even without a valid key

gitlinuxsshUbuntu

So I have done the same process over and over again and everytime worked perfectly, but on thie particular server it just won't work.

I've tried any written suggestion on the Internet + serverfault but nothing is working.

So shortly I need to clone a git repository in another server from the original server, but the ssh connection won't work. I tried to fix, but nothing worked.

Even without a key the same errors occurs:

ssh -p **** -vvv git@*host.domain*
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to *host.domain* [***.***.***.***] port ****.
debug1: connect to address ***.***.***.*** port ****: Connection timed out
ssh: connect to host *host.domain* port ****: Connection timed out

Also, something weird I've noticed after searching for fixes over the internet: I can't restart the ssh as it appears normally with sudo service ssh restart, only with sudo service sshd restart. Not sure if anything relevant.

Best Answer

If the connection is timing out rather than being refused immediately, this is most likely some kind of firewall problem. Obviously I can't know what devices are sitting between your client and server, so this answer is limited to the firewall on the server itself.

If you don't mind temporarily disabling your host firewall, you can test this by doing

# iptables-save > /tmp/ipt
# iptables -F
...try your ssh connection again...
# iptables-restore < /tmp/ipt

If that fixes it, you'll have to look at the output of iptables -nvL to work out which rule is blocking your connection.

If you still have problems, it's possible that sshd itself is dropping the connection for some reason. You could try running on the server

# tcpdump host [address of client] and port 22

while you try connecting to see if the traffic actually arrives. If you don't see anything appearing while you're trying to connect and you've done an iptables -F, it's likely that some intervening device is responsible for dropping the traffic.