Configure WordPress to connect to Mysql DB using SSH tunneling

Problem: Configure wordpress to use a remote mysql database only available using and SSH tunneling.

Stage:
I have a wordpress instance over an apache server on machine (called WP_server). WP_server, does not have Mysql server and has blocked port except 80 (http) and 22 (ssh).

In other place is another machine (Mysql_server) which has a MySQL instance. This server can provide a database to WP_server.

These two server have ssh access.

How should I configure wordpress to use ssh tunneling?

2 Answers
2

You should create a ssh tunnel between the 2 serves. Then you can connect from the WP with only the mysql server ip.

ssh -f [email protected] -L 2000:personal-server.com:25 -N

The -f tells ssh to go into the background just before it executes the command.

This is followed by the username and server you are logging into.

The -L 2000:personal-server.com:25 is in the form of -L local-port:host:remote-port.

Finally the -N instructs OpenSSH to not execute a command on the remote system.

via Revsys

Leave a Comment