Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Sftp with JSCH Fails with the error message : com.jcraft.jsch.JSchException: Auth fail

Jyothi
2013-06-10
2013-06-10
  • Jyothi
    Jyothi
    2013-06-10

    I am trying to sftp to Linux server from Windows environment using JSCH API. It is failing with this error message.
    com.jcraft.jsch.JSchException: Auth fail
    at com.jcraft.jsch.Session.connect(Unknown Source)
    at com.jcraft.jsch.Session.connect(Unknown Source)

    try {
    JSch jsch = new JSch();
    session = jsch.getSession("username", "host", 22);
    session.setPassword("password");

                        java.util.Properties config = new java.util.Properties();
    
                        config.put("StrictHostKeyChecking", "no");
                        session.setConfig(config);
    
                        session.connect(); // failing here
    

    }catch(Exception ex)
    {
    e.printStaclTrace();
    }

    Sftp to this server works with WinSCP and FileZilla clients.
    Any help/ideas would be greatly appreciated.

    Thanks,
    Jyothi