I wrote the following command in /etc/rc.local:
ssh -R 32400:192.168.0.100:32400 root@marcin.com -N
but it won't start.
Any idea why?
I wrote the following command in /etc/rc.local:
ssh -R 32400:192.168.0.100:32400 root@marcin.com -N
but it won't start.
Any idea why?
Maybe the network isn't ready yet, when rc.local is executed.
The following code will wait for the network before connecting:
(
until ping -nq -c3 W.X.Y.Z; do
# Waiting for network
sleep 5
done
ssh -R 32400:192.168.0.100:32400 root@marcin.com -N
)&
W.X.Y.Z is an IP address that is reachable and replies to pings. It maybe be the default gateway of your network, the Google DNS (8.8.8.8), etc.
Code between parenthesis runs in a new shell, and the & makes it run in background. It won't block the execution of rc.local.
The commands between until and done will be repeated until the ping is successful, i.e., it gets a reply (i.e., the network is up).