So I have a Ubuntu 16.04 system that's supposed to be running an SSH script that I wrote, every time the system boots up. This is my first time trying to get it to work, so it never has before.
The script is very simple:
while true; do sleep 60; ssh root@ip -i ~/.ssh/key -R xxxx:localhost:22; done
It's inside of a file called autossh.sh
.
To get the script to run automatically, I've tried to include it inside of /etc/rc.local (before exit 0), I've tried to add it to the list of startup applications from Ubuntu's GUI.
During both times I reboot the computer, I can see that the script is actually running, but it's not mapping a remote port to localhost 22 like the command is supposed to do. If I run the command manually, it works, but it just doesn't work upon boot.
Is there something obvious that I'm missing here that's preventing this script from working as it should?