1

I am attempting to connect to remote Ubuntu server via SSH, from my windows machine using PuTTY. However, I keep getting a timed out error and can't find any reason for it.

Attempting the connection from a console provides the following verbose output:

$ ssh -vvv <user>@<ip-address>
OpenSSH_7.5p1, OpenSSL 1.0.2k  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolving "<ip-address>" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to <ip-address> [<ip-address>] port 22.
debug1: connect to address <ip-address> port 22: Connection timed out
ssh: connect to host <ip-address> port 22: Connection timed out

where is my username, and is the address of the server.

I have run /sbin/ifconfig -a and confirmed that the ip address is correct.

I can login using the username I am attempting to ssh with, and that is fine.

/etc/init.d/ssh status on the server returns the following:

* ssh.service - OpenBSD Secure Shell Server
   Loaded: loaded (/lib/systemd/system/ssh.server; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2017-09-06 BST; 21min ago
...

21 minutes ago I restarted the server, having already attempted to restart the SSH service. Connections are still being timed out.

The firewall is configured to accept connections on port 22, so I don't see any issue here.

I am very limited with what I can actually do within the console I have access to, but I'm not sure what else I can check or try.

Edit:

Pinging the ip gives me this:

$ ping <ip-address>

Pinging <ip-address> with 32 bytes of data:
Reply from <ip-address>: bytes=32 time=14ms TTL=54
Reply from <ip-address>: bytes=32 time=14ms TTL=54
Reply from <ip-address>: bytes=32 time=14ms TTL=54

Telnet gives me no output:

$ telnet <ip-address> 22
$

Further, it is now letting me ssh (at least up to authentication, but that's a different issue entirely). No more issue, though I still don't what caused it in the first place

closed as off-topic by steeldriver, karel, user68186, Eric Carvalho, muru Sep 8 '17 at 7:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This describes a problem that can't be reproduced that seemingly went away on its own or was only relevant to a very specific period of time. It's off-topic as it's unlikely to help future readers." – steeldriver, karel, user68186, Eric Carvalho, muru
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Can you try this on your Windows PC: ping <ip-address> and telnet <ip-address> 22 and then post the results. – koni_raid Sep 6 '17 at 11:26
  • I have updated my question. For some reason, it is now working again – SelketDaly Sep 6 '17 at 11:55
  • Can you run this on the server and include the output: sudo netstat -tupln | grep ":22 " – jrtapsell Sep 6 '17 at 11:55
  • Unfortunately (annoyingly?) the console I was able to use wouldn't accept any pipe symbols, or allow copying/pasting commands – SelketDaly Sep 6 '17 at 11:56
  • 1
    Telnet giving no output is not a good sign, it should print something like this when it receives the banner SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 – jrtapsell Sep 6 '17 at 11:57
0

If you have access to the host with your Ubuntu machine you should try next:

  1. Check if ssh daemon is really running: sudo netstat -tnlp | grep ssh (list running processes applying filter for SSH daemon).
  2. Optional! Check if ssh daemon uses port 22 for remote connections cat /etc/ssh/sshd_config | grep Port. The output should be Port 22 or any other number.
  3. Check the firewall settings: sudo iptables -nL. If the number of rules is big redirect the output to a text file in your home directory sudo iptables -nL > $HOME/iptables.txt.
  4. Backup iptables rules to your home directory sudo iptables-save > $HOME/iptables.up.rules. Remove TEMPORARY all rules sudo iptables -F. (Later on to restore the iptables rules you can run sudo iptables-restore < $HOME/iptables.up.rules.)

Now your Ubuntu machine can accept any traffic so you should be able to connect to it remotely over ssh.

  • Thanks for your answer. Everything was set up correctly, just for some reason the connection was timing out. Somehow, it has started working again without me doing anything, so mystery solved, I guess! – SelketDaly Sep 6 '17 at 16:29

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