level9wizard
asked on
Connect Apache Ant remotely to MySQL over SSH tunneling
A hosting provider I'm working with has port 3306 blocked for public access on their firewall, they recommend connecting to MySQL over ssh tunneling. This works fine for MySQL Workbench as it provides such functionality, but I'm trying to get a similar thing going with Apache Ant so I can automate restoring databases. I'm trying to figure out if I'm doing this correctly, from what I've read <sshsession> in Apache Ant 1.8.x provides tunneling. But I'm not sure whether to use localtunnel or remote tunnel and I'm not sure if I'll be able to even do what I want over a tunnel. Any suggestions?
<sshsession host="example.com" username="user" keyfile="${sshKeyLocation} " passphrase="password">
<remotetunnel rport="3306" lhost="example.com" lport="3306"/>
<sequential>
<sql driver="com.mysql.jdbc.Dri ver" url="jdbc:mysql://example. com:3306/$ {databaseN ame}" userid="dbuser" password="dbpass">
<transaction src="temp.sql"/>
</sql>
</sequential>
</sshsession>
<sshsession host="example.com" username="user" keyfile="${sshKeyLocation}
<remotetunnel rport="3306" lhost="example.com" lport="3306"/>
<sequential>
<sql driver="com.mysql.jdbc.Dri
<transaction src="temp.sql"/>
</sql>
</sequential>
</sshsession>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project name="Release Builder" default="release" basedir=".">
<description><![CDATA[Rele
<!-- REQUIREMENTS: MySQL JDBC Driver, DatabaseNameParser, DomainFileName, jsch -->
<!-- Configuration -->
<property name="mysqlUser" value="root"/>
<property name="mysqlPassword" value="xxxxxxx"/>
<property name="sshKeyLocation" value="private.ossh"/>
<!-- End Configuration -->
<basename property="basedir.name" file="${basedir}"/>
<target name="release" description="Release to the live server">
<!-- Create the time stamp -->
<tstamp/>
<sshsession host="example.com" username="root" keyfile="${sshKeyLocation}
<localtunnel rport="3306" rhost="example.com" lport="3305"/>
<sequential>
<sql driver="com.mysql.jdbc.Dri
SELECT * FROM SiteTree LIMIT 1
</sql>
</sequential>
</sshsession>
</target>
</project>