Software Test/자동화
[ANT] SSH / SFTP 사용방법
킁스
2015. 12. 9. 16:34
1. SSH를 위한 jar를 $ANT_HOME/lib에 이동
- maverick-ant.jar 필요
- 위의 jar를 받을 수 있는 곳이 어딘지 모르겠음, 구글 검색으로 받음
2. SSH 사용방법
<taskdef name="ssh" classpath="com.sshtools.ant.Ssh" />
<target name="ssh_test"> <ssh host="127.0.0.1" username="root" password="password" port="22" version="2"> <exec cmd="sh /root/test/shelltest.sh" /> <exec cmd="rm -rf /root/test/test_data.txt" /> </ssh> </target> |
3. SFTP 사용방법
<taskdef name="ssh" classpath="com.sshtools.ant.Ssh" />
<target name="sftp_test"> <ssh host="127.0.0.1" username="root" password="password" port="22" version="2"> <sftp action="get" remotedir="/root/testdir" verbose="true"> <fileset dir="."> <include name="**/*.java" /> <include name="**/*.xml" /> </fileset> </sftp> </ssh> </target> |
4. sshexec 사용
sshexec 사용을 위해서는 jsch-x.x.xx.jar 필요 (jsch-0.1.53.jar)
<target name="case5" > <sshexec host="127.0.0.1" username="op1" password="op1" trust="true command="ls -al" /> </target> |