1. ant lib 경로에 jsch*.jar 업로드 (http://www.jcraft.com/jsch/)
2. build.xml 참고용 설정 (ant 호출하는 쪽)
<?xml version="1.0" encoding="UTF-8"?>
<project name="프로젝트" basedir="." default="ssh_test" xmlns:ac="antlib:net.sf.antcontrib">
<taskdef uri="antlib:net.sf.antcontrib" resource="net/sf/antcontrib/antlib.xml" classpath="ant경로/apache-ant-1.7.1/lib/ant-contrib-1.0b4.jar"/>
<property name="server.sshkey" value="/계정홈/.ssh/id_rsa"/>
<property name="server.host" value="SSH접속할서버IP및hostname"/>
<property name="server.port" value="SSH접속포트"/>
<property name="server.username" value="SSH접속계정"/>
<property name="src_dir" value="복사할원본파일경로"/>
<property name="dst_dir" value="SCP로전송될사본파일경로"/>
<property name="work_dtm" value="변수값"/>
<property name="work_cmd" value="SSH접속하여실행할파일경로"/>
<target name="init">
<echo>*********************************</echo>
<echo>Init Tasks...</echo>
<echo>*********************************</echo>
</target>
<target name="ssh_test" depends="init">
<echo>*********************************</echo>
<echo>SSH another host... </echo>
<echo>*********************************</echo>
<tstamp />
<echo>*********************************</echo>
<echo>SCP... </echo>
<echo>*********************************</echo>
<scp todir="${server.username}@${server.host}:${dst_dir}" keyfile="${server.sshkey}" passphrase="">
<fileset dir="${src_dir}">
<include name="**/*"/>
</fileset>
</scp>
<echo>*********************************</echo>
<echo>SSHexec... </echo>
<echo>*********************************</echo>
<sshexec host="${server.host}" port="${server.port}" trust="true"
username="${server.username}" keyfile="${server.sshkey}" passphrase=""
timeout="3600" failonerror="true"
command="cmd /V /C "set WORKDTM=${work_dtm}& ${work_cmd}""
/>
</target>
</project>
3. C:/command/build.bat 샘플 (ant로 부터 ssh를 이용해 호출 당하는 쪽)
@echo off
echo %WORKDTM%