10

I have recently installed an ubuntu 16.04. I have installed ssh server and the sshd service is up and running.

I have some other PCs in the same network (windows, mac, ubuntu 14.06) and I can ping the ubuntu pc from all of them, but I cannot connect using ssh from any.

For example, using putty from windows I get a "Network error: Connection Timed out".

Locally I can connect using ssh with the IP.

Any idea of what could be happening?

Thank you in advance for your help!!

Gonzalo.

  • 2
    I think you would typically get a connection refused, but have you made sure the firewall is off for testing? 'sudo ufw disable' – user508889 May 3 '16 at 17:32
  • 1
    Hi Brian, the ufw was enabled. Disabling it allows me to connect, thank you!!! – Gonzalo May 3 '16 at 17:37
  • When it is enabled, if I write 'sudo ufw status', it does not show any rules. Do you know why it could be rejecting connections to port 22 if there aren't any rules?!? – Gonzalo May 3 '16 at 17:38
  • John, putty have a saved setup, yes. But the same was happening with any ssh client. The issue is related to the firewall. – Gonzalo May 3 '16 at 17:40
  • 1
    @Gonzalo the default behaviour is to allow outgoing connections but block incoming ones IIRC - i.e. incoming connections must be explicitly enabled by appropriate rules – steeldriver May 3 '16 at 17:41
18

Instead of turning off your firewall completely, you could instead configure UFW to allow your SSH traffic: sudo ufw allow ssh or if you decide to run SSH on a different port: sudo ufw allow 2222/tcp

UFW by default will deny all incoming connections and allow all outgoing connections. You can find more information on how to configure UFW here: https://help.ubuntu.com/community/UFW

| improve this answer | |
  • 1
    This should DEFINITELY be the accepted answer as simply saying "I disabled my firewall" as the accepted answer - is going to wreak havok on others who read it and don't skim down to find they SHOULD NOT do that. Disabling a firewall is never a good idea even if default is block all. – Bruce May 3 '17 at 3:52
  • This is the best answer here... – PGallagher Oct 1 '19 at 21:07
4

It turned to be that the firewall was enabled.

After executing 'sudo ufw disable' I was able to remotely connect.

Thank you Brian and all for your help.

Regards,

Gonzalo.

| improve this answer | |
1

Other answers have pointed out most of the causes. I would add another reason for not able to ssh. If you ssh by password authentication method, it may be because your password is a bad one. Just update a decent password, it will work. This was driving me crazy to find out...

| improve this answer | |
0

Try port forwarding port 22 if you are trying to connect with a public IP address, because that would be the only reason why you can only connect to it using the local ip address of the server. Also yes if you are using the ufw firewall and it is enabled make sure you have 'ufw allow 22' executed. You can check this by running 'ufw status'.

| improve this answer | |

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.