This guide will take you through the steps of using Ngrok to access your Raspberry Pi device local port remotely for remote SSH, VNC, viewing web server and more. including an explanations of what is Ngrok and which path you should consider to take when scaling from a single Linux IoT device to tens and above.
Time to read:
When developing a web site, we almost always develop them on our local computers, hosting and debugging their functionalities. But when it needs to be deployed, the usual practice is to get a proper domain from a reputed website such as GoDaddy and upload all your files to a file server and host the website from there. But what if your specific task does not require such a complicated web hosting service and you only need access to your local server in the most affordable way possible?
Well, a simple and intuitive solution would be to use a service such as Ngrok.
Ngrok is a simple yet powerful tool that can be used to expose a web server/ port of a Linux/Windows or Mac device that resides behind a NAT router or a tight firewall to the world wide web. A device being behind a NAT router means that usually, the devices connected to the network cannot be accessed directly from the internet. But by using this tool, we can access any port in our devices from anywhere in the world.
Use cases of Ngrok:
Consider you’ve set up a Nginx web server and it’s up and running in your Raspberry Pi, in your local network. Now you need to access this web server through the internet, from anywhere else int he world. In order to do this, either you need to expose your device’s port to the internet, and this can be a security risk to the whole network. Therefore, you may use Ngrok to do this task easily and securely.
Setting up Ngrok on your Raspberry Pi/Linux Device
Then go to the ngrok dashboard and copy the link for Linux ARM.
After copying the link, navigate to a folder of your choice in your Raspberry Pi through the terminal using cd /path/to/a/folder command. You can choose any path that you have write access to. An example would be /home/ folder.
Then use wget <copied link=""> to download the </copied>ngrok-stable-linux-arm.zip to the current directory.
(example wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm.zip)
By issuing unzip ngrok-stable-linux-arm.zip the Ngrok executable can be extracted. (if unzip program is not available in your system, you may use sudo apt-get install unzip to install it)
Starting an ngrok tunnel
Type ./ngrok http <port number=""> to start Ngrok service, exposing the port. The <port number=""> can be any port you want to expose, in the example, the nginx server is running on port 80, therefore the command would be ./ngrok http 80</port></port>
Then you will be given a response similar to the above terminal output. You can then copy the highlighted URL to paste in a web browser to access the web server from anywhere in the world.
In most cases, just being able to access a port or a web server on your Raspberry Pi may not be enough. The Ngrok is a good solution when it comes to personal usage. It provides TLS security, authentication tokens and everything, however, when it comes to industrial grade IoT device management solutions, just accessing your Linux edge devices over the internet isn’t going to cut it. You’re going to need to be able to do a whole lot more, including, but not limited to:
This is where JFrog Connect comes in to assist you. We have built an all-in-one platform where you can perform all those tasks with ease, with a single click of a button.