Auto start ngrok

hi folks,

here is the problem,

I use Ngrok to access next cloud as I cant do port forwarding on the router.
now running ngrok is simple, after boot, i use ssh and type the following command
“./ngrok http 80”
if you have already setup an ngrok account all works well. I can go to my ngrok page and grab the url to acess next cloud easliy

Problem is that how can I make ngrok auto start on dietpi.

I know it has to be a custom script and I am really a noob trying to run something that he does not fully understand.
can someone please tell me what and how, it will be greatly appreciated.
and if you have any other service that does exactly the same, I can happily test it out.
old service that i used was tonido :wink: :wink:

you could try using root crontab to execute your command on boot. A one liner could looks like this.

crontab -l > file; echo "@reboot /path/to/ngrok http 80" >> file; crontab file; rm file;

Maybe you will get an error message about not existing root crontab, but this is fine.

ah I figured something out

Step 1: Place ngrok in /opt/ngrok/.

Step 2: Get authtoken from ngrok website, then add it to /opt/ngrok/ngrok.yml.

Step 3. Modify your own configrations in /opt/ngrok/ngrok.yml.

Step 4: Add ngrok.service to /lib/systemd/system/.

Step 5: Start ngrok service by typing:

systemctl enable ngrok.service
systemctl start ngrok.service


so now everytime it boots up it automatically logs in and i can get url from ngrok.


ngrok.service file should look like this

[Unit]
Description=ngrok
After=network.target

[Service]
ExecStart=/opt/ngrok/ngrok start --all --config /opt/ngrok/ngrok.yml
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
IgnoreSIGPIPE=true
Restart=always
RestartSec=3
Type=simple

[Install]
WantedBy=multi-user.target

yml file should be like this

authtoken: (put in the code from ngrok)
tunnels:
  ssh:
    proto: tcp
    addr: 22
  dashboard:
    proto: http
    addr: 80
  vnc:
    proto: tcp
    addr: 5900

yep using systemd is another alternative

Very interesting

Thanks for this!!!

Such as this
Warning a bit o’ language
dC-hecmyxr4