I am in the process of attempting to set up SSH forwarding so that I may
have a secure database connection for PHP scripts between a web server and
I have the SSH forwarding working fine manually in testing, but I need some
suggestions or ideas about what to do about connecting from PHP scripts.
There are two keys to the problem. The first is that in order to set up the
port forwarding with SSH, you need a user account on the remote host (in
this case, the MySQL server) to login with. The second is that a DB
connection to the MySQL server from the web server may not always be around
all the time (even using persistant connections in PHP), so the SSH
forwarding will close automatically because there is no activity -
basically, it needs to be open from bootup to shutdown (or at least from
Apache startup to subsequent shutdown).
Does anyone have any suggestions for solutions to this problem? As I see it,
there might be solutions something like this, but I'm not sure how to
1. Create a user account on MySQL host that has no shell (to be as secure as
possible, as no remote commands need executing).
2. Tell SSH somehow to keep forwarding open on the webserver host,
regardless of whether there is any traffic going over it.
Sorry if this is rather off-topic, but I thought this would be a suitable
pool of expertise to ask at, and it is partly related to MySQL.
Basil Hussain (basil.hussain@stripped)