I am trying to automate the deployment process through Ant build XML file. My Ant is of version 1.9.4. As part of that I am trying to send the built war file on to the remote Tomcat server. So, I am using the below code of SCP task.
<target name="scp_task">
<scp file="antproject1.war" todir="${username}@${ipaddress}:${tomcat.webapps.dir}" password="${password}"/>
</target>
Along with that I have ant-jsch-1.9.4.jar
in my ANT_HOME/lib
directory. And when I am trying to run the Ant command in Windows DOS command prompt. When run the command ant scp_task
, I am getting the message as
BUILD FAILED: C:\Users\USER.ssh\known_hosts (The system cannot find the file specified)
Please help what else should I have to add for the code so that I could deploy my war file perfectly.
You have to create the known_hosts
file in the given path with a public host key of the remote server.
The file uses a common OpenSSH format like:
example.com,93.184.216.34 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
You can also skip the host key validation, but only if you do not care about security (like if you are connecting within a private network).
<scp trust="true" .../>