php connect to mysql via ssh

php connect to mysql via ssh

am 12.09.2007 22:00:33 von mtuller

I would like to encrypt data passed between my web server and the
database server. I have looked all over, but don't see any information
on how to connect to mysql via ssh with php. Is it possible?

Re: php connect to mysql via ssh

am 12.09.2007 22:23:25 von zeldorblat

On Sep 12, 4:00 pm, mtuller wrote:
> I would like to encrypt data passed between my web server and the
> database server. I have looked all over, but don't see any information
> on how to connect to mysql via ssh with php. Is it possible?

You want to use SSH tunneling to do this. Basically, suppose PHP is
running on hostA and MySQL is running on hostB. You then SSH from
hostA to hostB like this:

ssh -L 3306:hostB:3306 hostB

What this says is "From hostA ssh to hostB. When you do that, make
port 3306 on hostA forward everything over to port 3306 on hostB."

Finally you tell PHP to connect to use localhost (hostA) as it's
database server and it should just magically work.

You can even set up the SSH connection on a different machine. So,
from hostC you would do:

ssh -L *:3306:hostB:3306 hostB

And then configure PHP to use hostC as it's database server.

Re: php connect to mysql via ssh

am 12.09.2007 22:26:22 von Andy Hassall

On Wed, 12 Sep 2007 20:00:33 -0000, mtuller wrote:

>I would like to encrypt data passed between my web server and the
>database server.

How about:

http://www.php.net/manual/en/function.mysql-connect.php

client_flags, MYSQL_CLIENT_SSL

>I have looked all over, but don't see any information
>on how to connect to mysql via ssh

Well, you could set up an SSH tunnel for the relevant port (3306, using the -D
flag, or use stunnel or something else like that) and run the standard
(unencrypted) MySQL protocol through the encrypted tunnel, but that's another
step on top of just using the built-in SSL support (assuming a non-ancient
version of MySQL, and that it works as advertised anyway).

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

Re: php connect to mysql via ssh

am 13.09.2007 05:26:06 von Jerry Stuckle

mtuller wrote:
> I would like to encrypt data passed between my web server and the
> database server. I have looked all over, but don't see any information
> on how to connect to mysql via ssh with php. Is it possible?
>

Try a MySQL newsgroup, such as comp.databases.mysql. MySQL has to be
set up for this communication.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: php connect to mysql via ssh

am 08.10.2007 18:05:11 von mtuller

I am not trying to connect via SSL, I want to tunnel through SSH.

On Sep 12, 10:26 pm, Jerry Stuckle wrote:
> mtuller wrote:
> > I would like to encrypt data passed between my web server and the
> > database server. I have looked all over, but don't see any information
> > on how to connect to mysql via ssh with php. Is it possible?
>
> Try a MySQL newsgroup, such as comp.databases.mysql. MySQL has to be
> set up for this communication.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

Re: php connect to mysql via ssh

am 08.10.2007 23:14:06 von Jerry Stuckle

mtuller wrote:
> I am not trying to connect via SSL, I want to tunnel through SSH.
>
> On Sep 12, 10:26 pm, Jerry Stuckle wrote:
>> mtuller wrote:
>>> I would like to encrypt data passed between my web server and the
>>> database server. I have looked all over, but don't see any information
>>> on how to connect to mysql via ssh with php. Is it possible?
>> Try a MySQL newsgroup, such as comp.databases.mysql. MySQL has to be
>> set up for this communication.
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================
>
>

You still need to be in a MySQL newsgroup.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================