首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Mac OS X下的Apache Ants sshexec任务和密码问题

Mac OS X下的Apache Ants sshexec任务和密码问题
EN

Stack Overflow用户
提问于 2010-08-30 20:26:20
回答 1查看 1.4K关注 0票数 2

我想在Mac中使用Apache Ant中的sshexec任务,如下所示:

代码语言:javascript
运行
复制
<!-- ... -->
<target name="uname">
    <sshexec host="${host}" keyfile="${user.home}/.ssh/id_rsa" username="${user}" command="uname -ar" />
</target>
<!-- ... -->

但是对于"ant uname“,我只会得到一个错误"Auth cancel”:

代码语言:javascript
运行
复制
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)

在尝试之后,我发现我必须将密码短语作为参数“密码短语”添加到任务中:

代码语言:javascript
运行
复制
<!-- ... -->
<target name="uname">
    <sshexec host="${host}" keyfile="${user.home}/.ssh/id_rsa" passphrase="my.secret.passpgrase" username="${user}" command="uname -ar" />
</target>
<!-- ... -->

但我已经完美地设置了Mac,为我的密钥链管理密码短语提供了有效的集成。这样我就不必每次都输入密码了。

有没有办法让sshexec和scp任务使用存储在我的密钥链中的短语?

EN

回答 1

Stack Overflow用户

发布于 2012-04-21 00:20:47

我自己也遇到了这个问题,我有一个替代的解决方案:从密钥对中删除您的密码短语。似乎jsch无法访问本地密钥链,因此您必须将密码放入ant任务中,或者将其从键中删除。下面是如何删除它:

代码语言:javascript
运行
复制
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.
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3600271

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档