Задача Apache Ants sshexec и проблема парольной фразы в Mac OS X - PullRequest
2 голосов
/ 30 августа 2010

Я хотел бы использовать задачу sshexec в Apache Ant под Mac OS X следующим образом:

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

Но я получу только ошибку "Auth cancel" для "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)

После игры я только что обнаружил, что мне нужно добавить мою фразу-пароль в качестве параметра «фраза-пароль» к задаче:

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

Но я отлично настроил Mac OS X с рабочиминтеграция для управления паролями в мою связку ключей.Поэтому мне не нужно каждый раз вводить фразу-пароль.

Есть ли способ, которым sshexec и задача scp могут использовать фразы, хранящиеся в моей цепочке для ключей?

1 Ответ

2 голосов
/ 20 апреля 2012

Я сам наткнулся на это и нашел альтернативное решение: удалите вашу фразу-пароль из пары ключей.Кажется, что jsch не может получить доступ к локальной цепочке ключей, поэтому вам нужно либо поместить фразу-пароль в задачу ant, либо удалить ее из ключей.Вот как это удалить:

prompt% ssh-keygen -p
Enter file in which the key is (~/.ssh/id_rsa): <just hit return if the file printed before the prompt is your key file>
Enter old passphrase: <your current passphrase>
Key has comment '~/.ssh/id_rsa'
Enter new passphrase (empty for no passphrase): <hit return to remove the passphrase>
Enter same passphrase again: <hit return again>
Your identification has been saved with the new passphrase.
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...