Article 5B7QT Automaticaĺly retrieve and save running tunneled port on ngrok

Automaticaĺly retrieve and save running tunneled port on ngrok

by
ciroreed
from LinuxQuestions.org on (#5B7QT)
Hello, Im using the free ngrok version (https://ngrok.com/)

ngrok is very useful. It tunnels TCP traffic from the internet to any port you pick bypassing NATs and firewalls.

Although the free version doesn't allow you to know which remote address is going to emulate that specific port. Every time you run the program it answers you back with the provided remote address and port, for example:

Code:$ ngrok tcp 22 -log stout
> ...
> t=2020-12-04T13:55:55+0100 lvl=info msg="started tunnel" obj=tunnels name=ssh-access addr=//localhost:22 url=tcp://2.tcp.eu.ngrok.io:14942
> ...The stdout prints many lines. I need to find the line that contains "started tunnel" and then look up for /tcp.*$/. Once I have that value I need to save it anywhere.

My knowledge of bash is not that good but I know that I can use grep to filter stdout, im looking for any help on how to run everything as a script:

- launch ngrok
- filter stdout
- track remote address and store it in a file
- discard further stout output

There are important features on the paid version and im going to use them eventually since I'll need once my prototype is ready.

Thanks in advance!latest?d=yIl2AUoC8zA latest?i=cMCtVF-VFJk:lKTy_Kz3QOc:F7zBnMy latest?i=cMCtVF-VFJk:lKTy_Kz3QOc:V_sGLiP latest?d=qj6IDK7rITs latest?i=cMCtVF-VFJk:lKTy_Kz3QOc:gIN9vFwcMCtVF-VFJk
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments