How to install and use Ngrok in Kali Linux

Welcome to today's blog post on how to install Ngrok in Kali Linux and how to use Ngrok in Kali Linux. So as the title says in this blog I will cover almost everything that you need to know to use Ngrok in Kali Linux. let's start with the introduction

What is Ngrok

Ngrok is a tool that helps developers easily make their locally hosted web servers accessible to the internet. It creates a secure tunnel, or pathway, between your local machine and the internet.

This allows others, such as teammates or collaborators, to access your web server as if it were hosted on a public server.

How Ngrok works

Let's understand with an example: Imagine you're a developer working on a new web application on your computer. This application is currently only accessible on your local machine, meaning you can only view it on your device.

Now you want to publish it publicly to show your friend or teammate. Here comes Ngrok, it acts like a bridge between your local machine and the internet. You can use it to forward your application on the internet.

Essentially, Ngrok makes your local machine temporarily visible on the internet through a secure tunnel, allowing others to access your development work remotely.

As Ngrok’s is used for port forwarding and tunnelling websites. So ethical hackers use it for pen-testing and tasks like web testing.

Features of Ngrok

  1. Secure tunnels: Ngrok creates secure tunnels that allow you to expose your local development server to the internet. This means that you can share your work with others without having to worry about security risks.
  2. Customizable URLs: You can choose a custom subdomain for your Ngrok tunnel, which can help to improve branding and security.
  3. Multiple protocols: Ngrok supports a variety of protocols, including HTTP, HTTPS, TCP, and UDP. This means that you can use Ngrok to expose a wide range of applications and services.
  4. Authentication: Ngrok offers a variety of authentication options, including basic authentication, OAuth, and SAML. This allows you to control who can access your tunnels.
  5. Traffic inspection: Ngrok allows you to inspect the traffic that is going through your tunnels. This can be helpful for debugging purposes.
  6. Free tier: Ngrok offers a free tier that includes basic features. This is a great way to get started with Ngrok and see if it is a good fit for your needs. It is a matter of use or choice.

Requirements for Installing Ngrok

A good internet connection: We'll be downloading packages from the internet.

Sudo privileges: "sudo" stands for "superuser do" and is a command used in Unix-like operating systems to execute commands with elevated privileges, typically requiring administrator or root access.

How to install Ngrok in Kali Linux

Now that you know the basics of Ngrok, let's move on to the installation process. There are three methods:

  1. Using the Kali Linux repository (apt package manager)
  2. Downloading the zip file from the official website
  3. Using Snap (application store for Linux)

We'll explore each method in detail in the next sections.

Let's see our first method. the first method is also an answer for how to install ngrok in Kali Linux using terminal?

Method 1. Install Ngrok in Kali Linux using apt

First of all, update your Kali Linux system as we do every time. So to update Kali Linux use the following commands.

sudo apt update && upgrade

Now what it does is update the package and install the latest version of all packages this will help in smooth installation.

Now run the following command to install ngrok in Kali.

curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | sudo tee /etc/apt/sources.list.d/ngrok.list

This command will add the ngrok's repository to Kali Linux so that we can easily install and update ngrok using apt.

add the ngrok's repository to Kali Linux

Now run the final command to install ngrok.

sudo apt update && sudo apt install ngrok

Now this will update the information and then install ngrok in Kali.

install ngrok in Kali.

Let's check if it is installed or not. Run the following command.

ngrok --version

This command will show the version of ngrok installed in your system.

Check version of Ngrok in kali linux

Method 2. Install by downloading the zip file of ngrok

So first of all go to the official download page of Ngrok. Head to Linux to section and here select X86-64 and download the ngrok's zip file for Kali Linux.

Install by downloading the zip file of ngrok

Now move to the download folder (where the package was downloaded) and run the following command:

sudo tar xvzf ~/Downloads/ngrok-v3-stable-linux-amd64.tgz -C /usr/local/bin

The command extracts the ngrok binary from the compressed archive and places it in the "/usr/local/bin" directory, which is typically included in the system's PATH environment variable. This allows you to run the "ngrok" command from any directory in your terminal.

install Ngrok in kali linux

Method 3. Install ngrok in Kali Linux using snap

Snap is a software packaging and distribution system developed by Canonical, the company behind Ubuntu. It allows developers to package their applications along with their dependencies into a single, self-contained unit called a "snap." These snaps can be easily installed, updated, and managed across various Linux distributions that support the Snap framework.

Now to install ngrok in Kali Linux using snap first we need to install ngrok in Kali Linux. run the following command.

sudo apt install snapd

This command will install snap using apt. Now we need to enable snap service so that we can install software using this so run the following command to enable the snap service.

sudo systemctl enable --now snapd.socket

Now finally run the installation command.

sudo snap install ngrok

Now I assume you have installed ngrok in your Kali system. let's know how to use it.

How to setup ngrok in Kali Linux

Now You'll need a Ngrok authtoken to use the tool. If you don't have one, sign up for a free account on the Ngrok website: https://dashboard.ngrok.com/signup

Ngrok authentication token is a unique code that grants access to Ngrok's services. It's like a password that allows you to securely use ngrok features, such as creating tunnels to expose your local servers to the internet.

Open the “auth tokens” section and create a token on the website. After you have a token run the following command.

ngrok config add-authtoken <token>

Replace <token> with the token you copied earlier.

add authtoken for ngrok in kali linux

And here we have finished the installation and setup process now I will tell you how to use ngrok.

How to use Ngrok in Kali

Starting a tunnel

To start a tunnel use the following command syntax:

ngrok <protocol> <port>

Replace <protocol> with the protocol you want to expose. For example, HTTP for a web server, TCP for a generic TCP port, etc.

Replace <port> with the actual port number of your local service.

Examples:

1. Expose a web server running on port 80

ngrok http 80

This command starts ngrok and establishes a secure tunnel to your local machine's port 80, that allows external access to any web server running on that port.

So this does not mean that ngrok is a webserver, to host a website using ngrok we need to set up the server separately.

how to start ngrok in kali linux

Here you can see a website is hosted on your local server and you can share this website using a Forwarding URL. So that people can access it from anywhere.

2. Expose a service running on port 2222 using the TCP protocol:

ngrok tcp 2222

This command starts ngrok and establishes a secure tunnel for TCP traffic to your local machine's port 2222.

secure tunnel for TCP traffic ngrok

Accessing your service

After running the command, Ngrok will create a secure tunnel and display information in the terminal, including:

  • Forwarding: The public URL for accessing your service.
  • Forwarding secure: The public URL for secure access (HTTPS).
  • Port: The local port is being forwarded.

Copy the public URL (Forwarding) and paste it into your web browser to access your local service remotely.

Note: if you face any while error using ngrok, you can find solution here https://github.com/inconshreveable/ngrok/issues

How to remove ngrok from Kali Linux

For method 1. Remove ngrok from kali using apt

It's so simple to remove ngrok if you installed it using apt. run the following command to remove it from Kali.

sudo apt remove ngrok

For method 2. Downloaded and extracted manually

If you installed ngrok by downloading the package from the official website then remove it from your machine. But first, you need to find where ngrok's binary is saved. to know this run the command:

which ngrok

This will typically output something like /usr/local/bin/ngrok. this is the directory where ngrok is located. Now we remove this to uninstall ngrok.

sudo rm -rf /path/to/ngrok

For method 3. If installed using snap

sudo snap remove ngrok

Run the snap list command again to confirm that ngrok is no longer listed among the installed packages.

Final thoughts

Overall Ngrok is a powerful tool that facilitates secure and convenient tunnelling for local development and testing purposes.

Overall, Ngrok is a powerful tool that simplifies and streamlines secure tunnelling for local development and testing purposes. This guide has provided you with a comprehensive overview of Ngrok, covering its functionalities, key features, and installation methods specifically tailored for Kali Linux users. Whether you choose the apt package manager, manual download, or the convenience of Snap, installing Ngrok is a straightforward process.

Additionally, we've included detailed instructions on using Ngrok within the Kali Linux environment, empowering you to leverage its potential and enhance your development workflow.

Stay tuned for more insightful guides, tutorials, and updates on Kali Linux tools and techniques. Follow us on social media for the latest news and subscribe to our newsletter to receive regular updates and exclusive content directly in your inbox.

Disclaimer:- pls note this article is only for educational purposes, if you misuse Kali Linux or ngrok, we are not responsible it's on you how to use this knowledge.

Pawan Verma

Hey there, I'm Pawan. I wear many hats in the world of technology, but if I had to sum it up in a nutshell, I'd say I'm a cyber security enthusiast. My passion for all things digital security led me to embark on a journey of continuous learning and exploration in this ever-evolving field.

Post a Comment

Previous Post Next Post