Skip to content
Advertisement

send Ngrok random port number through terminal

I use Ngrok service to forward my local network to the internet but for my specific application as I do not have access to hardware I need to run ngrok automatically after boot and send random port number and host address which ngrok assigns to my local port through sendmail package to a specific email address in terminal directly.So I can use it to connect to my system remotely. for example command below do this job for “ls”.It runs “ls” command and send the output to the given address:

ls|sendmail example@something.com

for ngrok I think maybe this works:

./ngrok tcp 22|sendmail example@something.com

but there is nothing happen!

would you help me how can I do this?

Advertisement

Answer

for running ngrok command after reboot, I suggest you to use crontab

crontab -e

 @reboot  /path/to/ngrok tcp 22 | sendmail example@something.com

please note that, If ngrok needs some environment variables, you need to set it. to do that you can create another .sh file (bash file), set environment variables then execute the command. then call that .sh file in crontab.

Advertisement