After a heated battle between myself and the computer, I finally have an answer that hasn't been discussed in any article I could find. I will post a blog about it.
The solution is to use a new feature only fixed in the alpha release of ant 1.8.3, which appears to just be a bug fix over the release version of 1.8.2, so it's probably stable enough even with the alpha title. That feature allows you to pass data to the STDIN of the script, namely the password. You can then use standard linux tools or cygwin on windows to read the password off STDIN and use it as a variable.
No dependencies, no key files, no leaked password on the command line, no stored passwords. I finally see some light beyond this dark dreary existence I've suffered through the last few days.
Here is an ANT task that does just this:
<input message="Enter username for ${website.host}:" addproperty="host.username" />
<input message="Enter password for ${website.host}:" addproperty="host.password" />
<sshexec host="${website.host}" trust="true"
username="${host.username}" password="${host.password}"
inputstring="${host.password}"
command='read var; expect -c "spawn sudo chmod u+x /usr/local/website/bin/start_website" -c "expect ${host.username}:" -c "send ${var}\r" -c "wait"' />
Note the command line:
read var; expect -c "spawn sudo chmod u+x /usr/local/website/bin/start_website" -c "expect ${host.username}:" -c "send ${var}\r" -c "wait"
First we read STDIN into variable var. We then fire up expect which performs some action requiring user interaction: sudo in this case. When sudo prompts us for the password we send it from the stored variable var and wait for the process to complete.
ps -ef). Don't do it. – ceving Jun 27 '11 at 5:45