本文介绍了“com.jcraft.jsch.JSchException:Auth fail”使用密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试将文件上传到我们的服务器时,我收到以下异常

While trying to upload the file to our server, i am getting the following exception

    com.jcraft.jsch.JSchException: Auth fail
        at com.jcraft.jsch.Session.connect(Session.java:464)
        at com.jcraft.jsch.Session.connect(Session.java:158)
        at FtpService.transferFileToReciever(FtpService.java:80)
        at FtpService.transferFileToReciever(FtpService.java:54)
        at FtpService.transferFileToRecievers(FtpService.java:44)
        at FtpService.transferSingeFile(FtpService.java:241)
        at FtpService.main(FtpService.java:26)
    Auth fail

源文件中函数transferFileToReciever的部分是

The part of function transferFileToReciever from source file is

        JSch jsch = new JSch();
        jsch.addIdentity("/root/.ssh/id_dsa");
        Session session = jsch.getSession(username, host, 22);

        session.setUserInfo(serverinfo);
        session.connect(); //geting exception here

        boolean ptimestamp = true;

密码正常工作,因为我可以使用ssh登录,但是使用JSCh它甚至无法工作用密钥,用户名和密码。
使用带有java版本1.6.0_25的id_dsa密钥。
可能是什么错误?

The passwords are working, since i can do login using ssh, but using JSCh it doesnt work even provided with key, username and password. Using id_dsa key with java version "1.6.0_25".What could be the error?

找到其他类似的问题,但不是答案。
提前谢谢。

Found other similar question, but not the answer.Thanks in advance.

推荐答案

追踪根本原因,我终于发现dsa类型的公钥不是添加到远程服务器上的授权密钥。附加相同的工作对我来说。

Tracing the root cause, i finally found that the public key of type dsa is not added to the authorized keys on remote server. Appending the same worked for me.

ssh正在使用rsa密钥,导致我回顾我的代码。

The ssh was working with rsa key, causing me to look back in my code.

谢谢大家。

这篇关于“com.jcraft.jsch.JSchException:Auth fail”使用密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 12:07