SSH tunnel to remote mysql database inside PHP script
Zur Navigation springen
Zur Suche springen
Open SSH tunnel to remte Mysql Datebase on port 3306 and mapp to local port 3308. Only if port 3308 is not used.
exec('nc -z localhost 3308 || ssh user@remotehost -4 -f -N -i id_rsa -L 3308:dbhost:3306 > /dev/null');