from sshtunnel import SSHTunnelForwarder
with SSHTunnelForwarder(('sshhost.domain.com', 22), ssh_password=
    'sshpasswd', ssh_username='sshusername', remote_bind_address=(
    'mysqlhost.domain.com', 3306)) as server:
    conn = MySQLdb.connect(host='127.0.0.1', port=server.local_bind_port,
        user='user', passwd='password', db='dbname')
ssh first with mysqldb in python