Ant Scp Task:
1)Ant Scp was an external task i.e it is not part of ant default installation.
2)Inorder to execute this we need copy required jar from the this link("http://www.jcraft.com/jsch/") and paste it into ant installation lib directory.
3)Then write build file as below:
Below example is for copying a single file for more info refer (https://ant.apache.org/manual/Tasks/scp.html)
<project name="scpdemo" default="test" basedir="." >
<target name="test">
<echo>Example of ant external task SCP </echo>
<scp file="temp.txt" todir="root@54.237.67.193:/home/ubuntu/AntDemo" password="root" trust="true" />
</target>
</project>
Note:In above scp task we set trust to true in order to establish connection with unknown destination host.An alternative for this is to add remote ip to our local machines host direcyoty.
4)Now run the build file and an important thing to note is if you are using remote host machine as ec2-instance linux machine.
Then it should fulfil these 2 criteria:
i)The user should have password rather than private key.
ii)The user should have privileges to access file system in remote machine i.e he should be root user.
Refer below link:https://bhuvanchandnotes.blogspot.com/2020/08/root-use-in-aws-linux-instance-httpwww.html
0 Comments