I have an ant script on a public server available to multiple users. I want to input a password into a script securely and use it for multiple targets. The following code gets a password with input, but the variable is not being passed to the sshexec task.
Will this work or is there a better way to do it?
<target name="get_password">
<input message="Enter Your Password:>" addproperty="password">
<handler classname="org.apache.tools.ant.input.SecureInputHandler" />
</input>
</target>
<target name="create_tmp_dir">
<sshexec host="${host}"
username="${username}"
password="${password}"
command="mkdir ${tmp_dir}" />
</target>
Ok...I see that I am a year late but for new comers this is how I solved the problem. My goal was to execute a command as root without revealing my password (obviously)
Finally I've created a bash script in ~/become-root.sh in my server that looked like this
If you call execute-command task you can now run commands as sudo (assuming that your user is sudoer)
Hope this helps!