Monday, November 1, 2010

How To Connect To Mysql With SSH tunnel

Remote connection of mysql is always pain for security concern ssh tunnel is best option  .


#! /bin/bash
# Copy This script to /usr/bin/

Tunnel_check="`sudo netstat -tulnp 3307 |grep 127.0.0.1:3307`"

if [ "$Tunnel_check" == "" ] ;then
        echo "Tunnel is really Running ?"
        /usr/bin/ssh -2 -f -C -N deploy@ec2-23.45.124.compute-1.amazonaws.com -L 3307/127.0.0.1/3306
else
        echo "Tunnel is Running"
fi

No comments: