Trying to SSH tunnel on startup

Hello everyone,

I'm trying to do SSH tunnel that go up on startup.
i wrote initscript:

#!/bin/sh /etc/rc.common

boot() {
while true
ssh -fN -R root@server -i /root/identityFile
sleep 10

The ssh command alone is running well but the initscript isn't running.

I would appreciate your assistance

It would be simpler to add that to rc.local.
Did you make it executable?
Did you enable it?

As you suggested, I changed it to rc.local.
and for both of your questions. yes its executable and enabled.

Still not working.

I suppose you added the ssh command only in the rc.local file, right?

like this:

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

ssh -fN -R root@server -i /root/identityFile

exit 0

While ago i tried to put while loop and my router stocked in boot loop :sweat_smile:

It won't work as it is ( lack of shell or something like that)
A couple of solutions: (be careful with the paths, not exactly the same with OpenWrt) (exists in opkg, should be the best to use).

Thank you.
It's works well.
Thank you very much

Which one did you use? Could you post the command line you used as well?

1 Like

I used this guide:

If any one will ever want toy do autossh, this guide is more relative to Openwrt and pay attention to the known bug in the guide:


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.