tags:

views:

29

answers:

1

I would like to use a sshexec task in Apache Ant under Mac OS X like this:

<!-- ... -->
<target name="uname">
    <sshexec host="${host}" keyfile="${user.home}/.ssh/id_rsa" username="${user}" command="uname -ar" />
</target>
<!-- ... -->

But i will only get an error "Auth cancel" for "ant uname":

BUILD FAILED
/build.xml:78: com.jcraft.jsch.JSchException: Auth cancel
    at com.jcraft.jsch.Session.connect(Session.java:460)
    at com.jcraft.jsch.Session.connect(Session.java:154)
    at org.apache.tools.ant.taskdefs.optional.ssh.SSHBase.openSession(SSHBase.java:223)
    at org.apache.tools.ant.taskdefs.optional.ssh.SSHExec.execute(SSHExec.java:190)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:390)
    at org.apache.tools.ant.Target.performTasks(Target.java:411)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1397)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1366)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1249)
    at org.apache.tools.ant.Main.runBuild(Main.java:801)
    at org.apache.tools.ant.Main.startAnt(Main.java:218)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

After playing around i just found out that i have to add my passphrase as a parameter "passphrase" to the task:

<!-- ... -->
<target name="uname">
    <sshexec host="${host}" keyfile="${user.home}/.ssh/id_rsa" passphrase="my.secret.passpgrase" username="${user}" command="uname -ar" />
</target>
<!-- ... -->

But i have perfectly setup Mac OS X with a working integration for the passphrases management to my keychain. So i don't have to enter the passphrase every time.

Is there a way that the sshexec and also the scp task can use the phrases stored in my keychain?

A: 

http://matthew.mceachen.us/blog/using-mac-os-x-keychain-for-ssh-526.html

Aaron Saunders
I tried the suggested solution but it didn't helped. The error message is the same as before. My system is not using the ssh-package of macports, which ssh => /usr/bin/ssh.
DerKlops