Linux – Connect to the Raspberry Pi via a public Internet

Connect to the Raspberry Pi via a public Internet… here is a solution to the problem.

Connect to the Raspberry Pi via a public Internet

I have a

raspberry pi and I have a program that can only be run from an app when I need it.
So, basically I need to connect from the public internet to my Raspberry Pi.
Not sure about this, I thought I needed to make my Raspberry Pi ssh from the public internet, i.e. connect directly via some IP address.

What should I do? I’m trying to connect to my linux system via simple ssh but it doesn’t work. Any guidance and advice?

Thanks

Solution

First, you should make sure that the ssh daemon is properly installed on your RP. You can install it

sudo apt-get update && apt-get install ssh

Next, you should try to connect to your SSH server locally

, that is, open a terminal directly on your RP and try to connect to the SSH server running locally :

ssh root@localhost

Or better yet, use the current IP address of the RP instead of localhost. If you can connect, everything works fine here. Now you can try to connect to your RP from another box in your local network. It should also work. If not, it is likely that your firewall is blocking outgoing SSH connections on this machine, or your RP itself is blocking incoming connections. Generally, it shouldn’t block it unless you’ve configured something like it with iptables, eg.

If you can

connect within your LAN, you can go one step further. You need to configure your router’s firewall to forward the ports required for SSH to your RP. Alternatively, many routers offer the ability to put hosts into so-called DMZs. This is great for testing as it gives you unrestricted access to the internet.

Next, you need to find your public IP address on the WAN side. There are many websites < a href="http://www.whatismyip.com/" rel="noreferrer noopener nofollow">like this shows your current external IP address. If everything is configured correctly, you should now be able to connect to root@ [your external IP]. It should work on your local network and on the internet. In addition, you should consider using a dynamic DNS service client in your RP or router so that you can connect to a static host name instead of changing the dynamic IP address.

Related Problems and Solutions