I have to setup port forwarding on system start and have this configured in my rc.local
runuser -l phpAdmin -c 'ssh -f -N -L 9904:localhost:3306 phpAdmin@<server>'
When rc.local is executed, is it executed as root?
rc.local is executed as root user, but this is not probably the place to start such tunnel because if you get any problem (even a temporary network problem), your tunnel will be stopped forever. A better solution is to put it in /etc/inittab file, so that your init process may run it in your correct runlevel, and respawn it if it crashes. If you run it from inittab remove the "-f" flag from ssh invokation, otherwise init will not be able to detect ssh failing.