Ant, download fileset from remote machine

一世执手 提交于 2019-11-26 23:12:42

Since you haven't specified I'll assume that your local and remote systems are unix based and therefore support rsync and ssh.

A more cross-platform solution is challenging...

Example

Configure SSH

Generate an SSH key (specify an empty passphrase):

ssh-keygen -f rsync

This will generate 2 files, corresponding to the private and public keys:

|-- rsync
`-- rsync.pub

Install the public key on the remote server

ssh-copy-id -i rsync.pub user@remote

Test that you can now perform a password-less login, using the ssh private key to authenticate:

ssh -i rsync user@remote

ANT

The "download" target invokes rsync to copy the remote file system tree locally. If required one can additionally specify rsync exclusions (see the rsync doco).

<project name="rsync" default="download">

    <target name="download">
        <exec executable="rsync">
            <arg line="-avz -e 'ssh -i rsync' user@remote:/path/to/data/ data"/>
        </exec>
    </target>

    <target name="clean">
        <delete dir="data"/>
    </target>

</project>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!