All ssh attempts at connecting to the WAN IP address fail. For example,

ssh user@Wan.IP.Address -vvv -p 2236
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to [] port 2236.
debug1: connect to address port 2236: Connection refused
ssh: connect to host port 2236: Connection refused


ssh user@Internal.IP.Address -p 2236 -vvv

succeeds when using a separate laptop.

Typical troubleshooting information:

  • sshd_config has been updated for new port and allows connections
  • ssh server is up and running, and has been reset between any configuration touches
  • ufw is disabled
  • port 2236 has been forwarded to the internal IP address of the desktop on the router
  • telnet and tcptraceroute on the port fail for the WAN IP address, but they succeed for the local IP address
  • iptables (have been flushed and reset multiple times):

    sudo iptables -L Chain INPUT (policy ACCEPT) target ||||||| prot opt source |||| destination ACCEPT |||| all -- anywhere |||| anywhere ACCEPT |||| all -- anywhere |||| anywhere |||| state RELATED,ESTABLISHED ACCEPT |||| tcp -- anywhere |||| anywhere |||| tcp dpt:2236

    Chain FORWARD (policy ACCEPT) target |||| prot opt source |||| destination

    Chain OUTPUT (policy ACCEPT) target |||| prot opt source |||| destination

    • netstat:

    sudo netstat -putan | grep LISTEN | grep 2236 tcp ||||| 0 ||||| 0 ||||||* |||||| LISTEN 5132/sshd tcp6 ||||| 0 ||||| 0 :::2236 ||||| :::* LISTEN 5132/sshd

    |||| bars are used for help with whitespace formatting.

  • This has nothing to do with Ubuntu. When connecting from outside your network the router needs port forwarding. – user589808 Apr 17 '17 at 17:02
  • Yeah, as @CelticWarrior said you need to forward some ports on your router – Android Dev Apr 17 '17 at 17:07
  • Your router also needs to support NAT hairpinning – steeldriver Apr 17 '17 at 17:15
  • I listed under typical troubleshooting that the port has indeed been forwarded on the router – LetsGoUbu Apr 17 '17 at 17:21
  • based off the info you have provided, like @CelticWarrior said,the issue isn't with Ubuntu. I understand that you said that you have setup port forwarding, but the problem most likely resides there. The fact that it works internally, means the SSH service is configured properly on your Ubuntu host, and the issue is either with the port forward or NAT setup in your router/wan firewall. – Gansheim Apr 17 '17 at 19:14

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.