What's new

How to create a custom service to run autossh or permanent ssh tunnel?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

rkk2025

Occasional Visitor
Hi,

Is there any way to create a custom service in a asuswrt-merlin router?

What I'm basically trying to achieve is to create a reverse tunnel to expose my openvpn server to the internet by using the "serveo.net" which allows to do that trough ssh.

But for that I need a way how to start the ssh tunnel automatically and reopen it whenever the connection drops. The way to achieve this is by using "autossh" or in a more spartan way have the "ssh" command in a loop, to reconnect whenever the connection is dropped. So far so good, but in order for this to run on its own, I need to implement it as a service or somehow start it in a persistent way.

Anybody can help me out with making this work or point me to the right direction? Greetings and thanks.
 
Asuswrt-Merlin does not have any notion of "service" unlike a Linux- based PC. Best location to run such a thing would be in the wan-start script.
 
Asuswrt-Merlin does not have any notion of "service" unlike a Linux- based PC. Best location to run such a thing would be in the wan-start script.

But how can I run a process without it to being closed after wan-start finishes? From what I understand if I detach the ssh process (With &) once the script that launched the it finishes, all child (inclusive detached ones) get all closed. What's the best way to keep the process running in the background in asuswrt?
 
But how can I run a process without it to being closed after wan-start finishes? From what I understand if I detach the ssh process (With &) once the script that launched the it finishes, all child (inclusive detached ones) get all closed. What's the best way to keep the process running in the background in asuswrt?

If the program doesn't fork, then you can use nohup or the ampersand modifier to force the service to spawn a separate process.
 
But how can I run a process without it to being closed after wan-start finishes? From what I understand if I detach the ssh process (With &) once the script that launched the it finishes, all child (inclusive detached ones) get all closed. What's the best way to keep the process running in the background in asuswrt?
Provided that the script is invoked from one of the system scripts (services-start, post-mount, etc.) with the "&" it will stay running. You don't even need to "nohup" it. I do this for a few of my scripts.
 

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top