On ubuntu 14.04 I have installed openssh, changed the ssh port. I can login within LAN with no problems, but I cannot access it from outside.

I also have: allowed it though firewall and set up port forwarding on my linksys router

Whenever I login, I get the error (I have replaced # instead of numbers):

ssh: connect to host #.#.#.# port #: Can't assign requested address

What else can I check, what could be wrong? Please help.

  • From outside, what is the output of ping #.#.#.# ? Jun 14, 2015 at 19:43
  • Is that an apple error? Jun 15, 2015 at 0:21
  • Cannot ping (request timeout). Not an apple error, does not work on windows neither. I have also disabled the router firewall (temporarily for testing).
    – Jake B.
    Jun 15, 2015 at 12:53

3 Answers 3


for me, it helped to use the key aiming the ssh to use IPv4 instead of IPv6

ssh -4 .... 

There could be different reasons:

First of all I will assume that you ssh server is listening in the correct IP/interface, anyway an easy way to ensure it would be by typing in the ssh server:

netstat -putan |grep ssh

or depending on your OS type/version:

ss -putan |grep ssh

In case listening in the correct interface, check also if your SSH server is listening in tcp, tcp6 or both.

Sometimes, if you listen in both tcp and tcp6 (that would mean that you would be listening in IPv4 and IPv6), it can give you problems... You can only listen in IPv4 by editing the ssh configuration file /etc/ssh/sshd_config and adding/editting this value:

AddressFamily inet

After this change you would have to restart the SSH server.

Even if in this case you cannot access by SSH, I would recommend pinging the destination IP. If you receive no response, check IP/mask in both sides as well as the routing tables. The routing tables can be checked by the command:

ip route

You can set this as a client option to stop using IPv6.


Host *
    AddressFamily inet

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .