How to Install and Use Ngrok on Linux

How to Install and Use Ngrok on Linux

Learning how to install and use ngrok on Linux gives you complete access to the World Wide Web (www). Here’s everything you need to know about the service and how to deploy it. 

Ngrok is a service that allows accessing remote services over the internet without port forwarding. It primarily hosts the services in the sub-domain of ngrok. The main benefit this service offers is it allows our websites to be accessed from anywhere over the internet—without actually owning any domain name. 

Developers use it to show their projects and their functionality to clients. 

How to Install and Use Ngrok on Linux

Here we will discuss ngrok, a service that allows making local resources available over the internet. We will talk about its installation, configuration, and usage in the following few sections.

Usage of ngrok

You can make these resources public or share local resources like websites. For instance, if you have a local server running on Linux at loop back address, then ngrok can generate a uniform resource locator (URL) pointing to your loopback address (http://localhost:8080 or 

Besides the use case discussed above, there is another usage of the ngrok service. You can share your services externally over ssh. Security specialists can also test clone phishing techniques using ngrok. The ngrok command exposes local services behind NAT and firewalls to the internet via tunneling.

Installing ngrok

We will now discuss the installation step for ngrok. We must first register an account, then install (using the desired options) the ngrok service. The authentication token is configured, and you are ready to use ngrok.

Register your account

To install grok, ensure that you have an account registered on the dashboard. Once you register your account, you will receive a confirmation email. 

Installation of webserver

Make sure that you have a web server installed on your computer such that you can share its services over the internet. If it is not installed, run the following command to install the apache web server (for Ubuntu):

$sudo apt install apache2

For Red Hat users, the following command can be used for installation:

$yum install httpd

Installation of ngrok

There are two basic approaches for the installation of ngrok:

  • Using the snap package manager 
  • Download the compressed binary file
Installing via snap package manager

To install the ngrok using the snap package manager, execute the following command:

sudo snap install ngrok
Installation using compressed binary

To install ngrok from compressed binary, first, download it. Then, you need to extract it by executing the following command:

sudo tar -xvzf ngrok-v3-stable-linux-amd64.tgz

Here, we have used the tar utility, and the options provided are -x for extracting, -v for verbose, z for zipping, and f for force. You can also unzip it using the following command:


Tip: There is another approach to installing ngrok via apt. Simply run the following command:

$curl -s | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && echo "deb buster main" | sudo tee /etc/apt/sources.list.d/ngrok.list && sudo apt update && sudo apt install ngrok

Configuration of the auth token to use ngrok

After installation of ngrok, run its graphical user interface. There you will find the authentication token. If you have installed it using the snap package manager, run the following command:

$ngrok config add-authtoken <auth_token>

Here, provide the authentication token you copied from the graphical user interface. If you have installed using binary, then run the following command:

./ngrok config add-authtoken <auth_token>

At this point, you have to provide the authentication token copied from the GUI.

After performing the above steps, ngrok is ready to be used. A quick look at the details of the ngrok command can be seen via the help available for that command:

$ngrok help <command>

Steps to share a local website using ngrok

This section will discuss the basic steps to share a local website over ngrok. Make sure that you have a web server installed. Now, run the following command:

$ngrok http 80

You will be shown a URL to access the local website. Copy the URL and paste it into your browser. You may receive a warning message. Press the ‘Visit Website’ button. 

Now to quit ngrok, press “Ctrl + C”.

Making a computer remotely accessible via a secure shell (ssh)

If you have installed the ngrok using snap, run the following command to make it accessible from the remote system:

ngrok tcp 22

Run the following command to make the computer remotely accessible if you have installed ngrok using binary:

./ngrok tcp 22

You will be shown an address starting with tcp://. Copy it. Now, you can connect remotely to the computer using the following command:

ssh <User>@0<ProvidedURL> -p <Port>

Don’t include TCP in the previous address; specify the port with the –p option. 

And that brings us to the end of this article. Here, we tackled how to install and configure ngrok. We also discussed how ngrok could be used to share a local website remotely accessible over the internet. In addition, we even learned how a system is made available over SSH. 

The learning outcome of this guide is that users can make the website and applications hosted locally available over the internet.

If this guide helped you, please share it. ?

Leave a Reply
Previous Article
How to Install Onedrive on Linux Mint

How to Install OneDrive on Linux Mint

Next Article
How to Install XFCE on Linux Mint

How to Install XFCE on Linux Mint

Related Posts