Custom startup script for auto-login by ssh to remote host

I want my TL-WR710N router with LEDE 17.01.4 to auto-login to remote host by ssh at startup. The remote host is the internet access control server of my internetprovider.
There is nothing to do then holding open the ssh session all the time the router is running. If the ssh session drops then the router shall establish a new session within some seconds.

This script worked, when I put it to nvram/rc_startup variable of old dd-wrt version

while true
   DROPBEAR_PASSWORD='passwod' ssh -y
   sleep 5

Now I tried to put this script into startup section of LuCi (/etc/rc.local).
But the routers LED never stopped blinking after reboot, the router didn't respond to "reboot" anymore and every 5 seconds there have been ssh errors in syslog

ssh: Failed reading termmodes
exited: Failed to set raw TTY mode

I think there mustn't be an infinite loop in /etc/rc.local. The loop probably caused that the common startup didn't come to its end and therefore the LED didn't return from flashing to normal state.

How is the best way to adapt the script to LEDE?

Will this work for /etc/rc.local?

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

echo 'while true'>/tmp/studnetlogon
echo 'do'>>/tmp/studnetlogon
echo 'DROPBEAR_PASSWORD='mypwd' ssh -y'>>/tmp/studnetlogon
echo 'sleep 5'>>/tmp/studnetlogon
echo 'done'>>/tmp/studnetlogon

chmod +x /tmp/studnetlogon


exit 0

I would try to do it "the right way": have a look to the scripts at "/etc/init.d/", and see how it is done for other daemons that run continuously.

I would prefer a solution with LuCi, so that other (non IT) people with same problem can easily edit their username and password.

Maybe it'll work if you add -t to the ssh command. You could also try setting a specific terminal with TERM=, but I don't think that should make any difference. vt100 is the default.

The exit 0 part will not be reached with your current setup. Maybe it is enough to add & to the /tmp/studnetlogon command, but it might get killed when the init script exits. If so then look at the nohup command (separate package). Another option is using the screen command (also separate package). That might help with the errors as well.

Yes, if I add & to /tmp/studnetlogon then /etc/rc.local reaches its end and everything seems to be fine with the common startup of the router.
And no, /tmp/studnetlogon gets not killed when /etc/rc.local exits.

-t didn't change anything with the ssh errors.
But I discovered this with google
DROPBEAR_PASSWORD='password' ssh -y < /dev/ptmx
and then the ssh logon worked

Additionally I added logger commands to see in syslog what is going on.

This is now my /etc/rc.local

echo '#!/bin/sh'>/tmp/studnetlogon
echo 'while true'>>/tmp/studnetlogon
echo 'do'>>/tmp/studnetlogon
echo 'logger "studnet start"'>>/tmp/studnetlogon
echo 'DROPBEAR_PASSWORD='mypwd' ssh -y root@ < /dev/ptmx'>>/tmp/studnetlogon
echo 'logger "studnet stop"'>>/tmp/studnetlogon
echo 'sleep 5'>>/tmp/studnetlogon
echo 'done'>>/tmp/studnetlogon

chmod +x /tmp/studnetlogon


exit 0 

If I kill the process of the ssh session at remote host, then 5 seconds later a new session is created.

Can anybody help how I can send the output of ssh to syslog?