com.jcraft.jsch.JSchException:验证取消 [英] com.jcraft.jsch.JSchException: Auth cancel

查看:94
本文介绍了com.jcraft.jsch.JSchException:验证取消的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写 Ant 脚本以通过端口隧道检索 URL.

I'm trying to write an Ant script to retrieve an URL via port tunnelling.

当我使用密码时效果很好(名称 xxxx 出于隐私考虑):

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>

我收到此异常:

/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?

    推荐答案

    我调试了代码.这是失败的,因为我的私钥没有通过身份验证;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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆