Welcome Guest, Not a member yet? Register   Sign In
SSH tunnel for MySQL on remote server
#3

(This post was last modified: 02-18-2017, 10:19 AM by skunkbad.)

(02-18-2017, 03:48 AM)Diederik Wrote: I would use ssh -L on the php server to port fordward a local port through the ssh tunnel.

I've been trying that, with limited success, and not sure what's going on.

Code:
ssh -L 3307:123.123.123.123:3306 -p 2233 [email protected] -N


3307 because this local machine already has MySQL running on 3306.

example.com only allows SSH connections on port 2233.

I can do passwordless SSH connection just fine if I'm not using -L, and assuming it's making the connection with -L.

My CI database connection using 127.0.0.1 and port 3307 appears to not be tunneling, because on the local machine if I stop MySQL then my connection errors indicate the tunnel was not working.


If I can get this to work, I want to be able to start and stop the tunnel when I'm done, so I thought I'd run the ssh command through PHP's shell_exec, so I could get the PID. Then I could kill the PID when I'm done. Right now, I can't even get it to work by putting the command in the terminal.
Reply


Messages In This Thread
RE: SSH tunnel for MySQL on remote server - by skunkbad - 02-18-2017, 09:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB