5

I have an existing build.properties file that uses scp like this:

<scp todir="${linux.user}@${linux.site}:@{todir}" keyfile="${ssh.keyfile}" passphrase="${ssh.passphrase}" trust="yes" verbose="@{verbose}">
   <filestocopy />
</scp>

The documentation for that command is here: https://ant.apache.org/manual/Tasks/scp.html

I would like to move to ssh-agent and eliminate the passphrase. Some people who are using this have configured their ssh to NOT use passwords and leave passphrase blank.

One alternative is to use http://www.jcraft.com/jsch-agent-proxy/ , but I found this 1.5 year old question that says it is not supported yet:

https://stackoverflow.com/questions/19684309/can-ant-using-ssh-encrypted-private-key-from-pageant

This is used in many ant scripts so I need a plan that would allow me to use ssh-agent while still allowing others to continue with their method.

I am on Windows 7 trying to scp files to Linux. I have a Pageant compatible ssh-agent: KeePass2/KeeAgent.

2

Not exactly what you asked for, but I've solved my similar problem (within Maven Antrun plugin on OS X) by using the exec task instead. So you might use, for example, something like this to replace what you have:

<exec executable="pscp">
   <arg value="dirtocopy"/>
   <arg value="-r"/>
   <arg value="-i"/>
   <arg value="${ssh.keyfile}"/>
   <arg value="${linux.user}@${linux.site}:@{todir}"/>
</exec>

It's not ideal of course. For cross-platform support you'd require everyone to have an SCP implementation already installed, and you'd need conditionals to choose between scp on *nix and pscp or whatever on Windows.

However it has some advantages – ssh-agent integration just works (as per your original request), and you probably don't need the -i argument I've included for completeness.

Caveat: I haven't actually tested this with the PuTTY suite or on Windows

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.