0

How can I use my new openssh-server with the external IP address from outside the Local Area Network?

The purpose is that an external computer administrator from outside the Local Area Network should be able to administer the openssh-server (root rights, installation of software and data) via Internet.

Technical setup:

Local Area Network = Router + openssh-server + openssh-client

openssh-server Ubuntu 14.04.1 server full disk encryption internal IP 111.111.111.111, external IP address given by the Internet Service Provider 222.222.222.222, two free ports 22 (TCP, UDP) set in the router for this computer, user MaximGorki

openssh-client Ubuntu 14.04.1 desktop full disk encryption internal IP 111.111.111.110, external IP address given by the Internet Service Provider 222.222.222.222

I am able to login into the openssh-server from the openssh-client inside a Local Area Network (LAN) using the IP address set by the router for the openssh-server 111.111.111.111.

From the openssh-server I want to connect with the openssh-server with the command line:

ssh MaximGorki@111.111.111.111

ssh MaximGorki@222.222.222.222

The internal IP address works with password.

The external IP address does not work from the openssh-client computer which is within the Local Area Network:

ssh: connect to host 222.222.222.222 port 22: Connection timed out

I have set up also pubkey feature. But this does not work. I do not know why. Therefore, I would be happy to access the openssh-server only by password authentication.

I want to test if the openssh-server is available from the external IP address.

What do I have to set up or change in which computer how?

My linux know-how is very limited, please give full command line syntax as examples, if you see the answer.


After recommendation of one answer I added 4 rules to the original iptables. Iptables look now so:

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)

pkts   bytes   target   prot   opt   in    out   source

218    16703   ACCEPT   all    --    any   any   anywhere state RELATED,ESTABLISHED

0       0      ACCEPT   all    --    any   any   222.222.222.222 

0       0      ACCEPT   tcp    --    any   any   anywhere tcp dpt:22

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)

pkts   bytes   target   prot   opt   in    out   source

0      0       ACCEPT   all    --    any   any   anywhere state RELATED,ESTABLISHED

0      0       ACCEPT   all    --    any   any   anywhere state RELATED,ESTABLISHED

0      0       ACCEPT   all    --    any   any   anywhere state RELATED,ESTABLISHED

Chain OUTPUT (policy ACCEPT 10 packets, 2082 bytes)

pkts   bytes   target   prot   opt   in    out   source
2

My mistake was not setting the ports in the ssh_config, sshd_config and router to the same number. Earlier, I changed the port numbers. I mixed up the config files for the server and the client. Now all ports in all config files and in the router have the same number. Now I can access the server from the client using the external IP address.

  • Please delete the question as it is very unlikely that anyone have similar problems. – user68186 Oct 16 '14 at 20:59
0

For this, you would need to forward the port you are trying to connect through on your router. You can Google around for instructions on this, as it varies a lot with different manufacturers and models.

  • I have written already, maybe you did not remark it because my text is long: two free ports 22 (TCP, UDP) set in the router – Robert Oct 15 '14 at 18:45
0

Check the iptables for firewall restriction. Try adding the below lines in Iptables and check whether you are able to access the machine via ssh

-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -s 222.222.222.222 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT

If the above is not working check you router setting whether the port is forwarded correctly

  • I applied the 4 rules by typing sudo iptables -A INPUT ... Then I tried to connect from the openssh-client which has ip 222.222.222.222 via the ip address 222.222.222.222 Result was connection timed out I checked the free port 22 in the router It seemed OK. Then I checked iptables -L -v see results above – Robert Oct 15 '14 at 18:48
0

Have you ensured that your router can (and has enabled) NAT Loopback / Hairpinning?

If not, you can't connect to a device on your LAN through your external IP. Try tethering a phone to your client instead of using your LAN internet connection to test. Alternatively use a proxy, VPN or simply try establishing the connection from another network.

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.