Hi,
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
do
DROPBEAR_PASSWORD='passwod' ssh -y username@ip.of.remote.host
sleep 5
done
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 username@ip.of.remote.host'>>/tmp/studnetlogon
echo 'sleep 5'>>/tmp/studnetlogon
echo 'done'>>/tmp/studnetlogon
chmod +x /tmp/studnetlogon
/tmp/studnetlogon
exit 0
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.