Return to Snippet

Revision: 31088
at August 29, 2010 20:39 by moonbather


Initial Code
PRODUCTION_PORT=33006
[email protected]

#connect to the tunnel and put the connection to the background
ssh -f -N -L $PRODUCTION_PORT:localhost:3306 $PRODUCTION_SERVER_AUTH

...
(do some mysql work by connecting to localhost)
...

#Find the PID of the ssh tunnel in the background and assign it to a variable
PID=$(ps -eo pid,args | grep 'ssh -f -N -L 33006:localhost' | grep -v  'grep' | cut -c1-6)

#kill the tunnel
kill -9 $PID

Initial URL

                                

Initial Description

                                

Initial Title
mysql ssh tunnel (then kill PID)

Initial Tags
mysql, ssh

Initial Language
Bash