My server runs Ubuntu Server 14.04. When connecting over SSH from a local LAN client it works fine. When I connect using a different machine from an outside network, I get 'connection timed out'.

I cannot figure out why.

My router is configured to forward external port 51887 to port 22 on the Ubuntu server, and to forward a second port 51888 to port 22 on my Macbook.

Connecting to the SSH server on the Macbook -in the same LAN as the Ubuntu server- and from the same remote client, works fine. So that leads me to conclude the problem is not in the router/port forwarding.

I have tried running the SSH server on Ubuntu on a non-standard port 22000 (and updated the port forwarding rule) with no change in result.

I have verified that ufw and iptables are not active. I changed none of their default settings since installing the server.

I have been looking at /var/log/auth.log and I can see the local connects but there is nothing logged for the remote connects, suggesting they do not reach the server?

So I can connect to the Ubuntu server over SSH locally, and I can also connect remotely to the Macbook over SSH, but I cannot connect remotely to the Ubuntu server.

I'm stumped, having spent several days on this and reading tons of askubuntu topics and other resources. Anyone with a good suggestion?

EDIT: The port forwarding of the router looks like this: Router Port Forwarding

EDIT: Output of netstat and iptables:

myuser@server:~$ sudo netstat -natp | grep 22
tcp        0      0    *               LISTEN      1291/sshd       
tcp        0      0    ESTABLISHED 1645/sshd: myuser 
tcp6       0      0 :::22                   :::*                    LISTEN      1291/sshd       
myuser@server:~$ sudo iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
  • That refers to preventing an established connection from timing out; my issue that I cannot establish a connection in the first place - attempting to do so results in the timeout. – markjan Mar 8 '16 at 11:35
  • My guess is then that you need unique ports for port forwarding. Use port xxx for your mac, and xxx +1 for Ubuntu. – Panther Mar 8 '16 at 11:38
  • Yes, as mentioned I do have two separate ports forwarded for the Ubuntu and Mac machines. – markjan Mar 8 '16 at 13:12
  • If you can connect on your LAN, but not over the internet, is is most likely a port forwarding or routing problem and I can not really tell from what little you posted. – Panther Mar 8 '16 at 13:22

Your Answer

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

Browse other questions tagged or ask your own question.