Hello.
I need to connect one-another datasource, but access open just by ssh-tunnel. Can I configure datasource with connection by ssh-tunnel, and if it possible, how can I do it?
Thank you.
This isn’t really a task PHP should do.
Instead open the SSH tunnel in your server like
ssh -fNg -L 3307:127.0.0.1:3306 <remote-user>@<remote-ip>
3307
=> new local port which can be used in CakePHP to connect to
127.0.0.1
=> localhost
3306
=> remote port where MySQL listens to on the remote server
<remote-user>
and <remote-ip>
should be self explenatory
and then just use that local 3307 port instead of the default 3306 port to connect to the remote database (in the config/app_local.php)
If you don’t want to manually open the SSH tunnel everytime e.g. the machine restart you can look at