com.jcraft.jsch.JSchException:验证取消 [英] com.jcraft.jsch.JSchException: Auth cancel
问题描述
我试图写一个Ant脚本来获取通过端口隧道的URL。
I'm trying to write an Ant script to retrieve an URL via port tunnelling.
当我使用一个密码(xxxx'd出对隐私的名字),它的伟大工程:
It works great when I use a password (the names xxxx'd out for privacy):
<project default="main">
<target name="main">
<sshsession host="xxxx"
username="xxxx"
password="xxxx">
<LocalTunnel lport="1080" rhost="xxxx" rport="80"/>
<sequential>
<get src="http://localhost:1080/xxxx" dest="/tmp/xxxx"/>
</sequential>
</sshsession>
</target>
</project>
但是当我使用一个密钥文件,这样它不工作:
But it doesn't work when I use a keyfile, like this:
<sshsession host="xxxx"
username="xxxx"
keyfile="/Users/xxxx/.ssh/id_dsa"
passphrase="xxxx">
<LocalTunnel lport="1080" rhost="xxxx" rport="80"/>
<sequential>
<get src="http://localhost:1080/xxxx" dest="/tmp/xxxx"/>
</sequential>
</sshsession>
我得到这个异常:
I get this exception:
/tmp/build.xml:8: com.jcraft.jsch.JSchException: Auth cancel
at com.jcraft.jsch.Session.connect(Session.java:451)
at com.jcraft.jsch.Session.connect(Session.java:150)
at org.apache.tools.ant.taskdefs.optional.ssh.SSHBase.openSession(SSHBase.java:223)
- 我敢肯定,我使用的是正确的密钥文件(我已经使用了错误的名称,这给出了一个合理的FileNotFoundException异常试过)。
- 我可以成功地在命令行ssh登录而不被提示输入密码。
- 我敢肯定,我使用的是正确的密码的密钥文件。
这是什么错误的原因,我能做些什么呢?
What's the cause of this error and what can I do about it?
推荐答案
我调试的code。这是失败,因为我的私人密钥认证失败; JSch默默回落至密码验证,被取消了,因为我没有指定密码。
I debugged the code. This was failing because my private key was failing authentication; JSch silently fell back to password authentication, which was canceled, because I didn't specify a password.
JSch错误处理吸了很多。追溯你的步骤,重新生成(单独)私钥文件,使用的ssh -i
来保证你使用正确的文件,并保持你的手指交叉。
JSch error handling sucks a lot. Retrace your steps, regenerate a (separate) private key file, use ssh -i
to guarantee you're using the right file, and keep your fingers crossed.
这篇关于com.jcraft.jsch.JSchException:验证取消的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!