com.jcraft.jsch.JSchException: Auth fail error

Kriz

Trying to connect to a host using ssh key auth. Below is my code:

package com.mkyong.common;

import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;

/**
 * 
 */
public class UserAuthPubKey {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
      try {
            JSch jsch = new JSch();

            String user = "XXXXXXXX";
            String host = "XXXXXXXX.XXXXXXX.com";
            int port = 22;
            String privateKey = "~/.ssh/WF_OPENSSH.ppk";
            String passphrase = "XXXXXXXXXXX";

            jsch.addIdentity(privateKey,passphrase);
            System.out.println("identity added ");

            Session session = jsch.getSession(user, host, port);
            System.out.println("session created.");

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

            session.connect();
            System.out.println("session connected.....");

            Channel channel = session.openChannel("sftp");
            channel.setInputStream(System.in);
            channel.setOutputStream(System.out);
            channel.connect();
            System.out.println("shell channel connected....");

            ChannelSftp c = (ChannelSftp) channel;

//            String fileName = "test.txt";
//            c.put(fileName, "./in/");
//            c.exit();
//            System.out.println("done");

        } catch (Exception e) {
            System.err.println(e);
        }
    }
}

what change should i make here. On debugging the error seems to occur at session.connect(); statement. I am using a private key and a passphrase to connect.

Kenster
String privateKey = "~/.ssh/WF_OPENSSH.ppk";

Is that a PuTTY-format keyfile? Was it generated from puttygen, the PuTTY key generation utility? Jsch only reads OpenSSH-format key files, not PuTTY-format files.

You can use puttygen to convert the key to OpenSSH format if you want to use that key. See this question.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Testing jsch on gitlab results in invalid privatekey error

From Dev

Width="*" in longlistselector giving error "Error HRESULT E_FAIL has been returned from a call to a COM component"

From Dev

com.jcraft.jsch.JSchException: Auth fail error

From Dev

Laravel Auth::logout() Fail

From Dev

SFTP via JSch is throwing error 4: Failure

From Dev

com.jcraft.jsch.JSchException: java.net.ConnectException: Connection refused: connect

From Dev

Yowsup auth fail whatsapp

From Dev

Jsch connection with private key fails with com.jcraft.jsch.JSchException: Auth fail error

From Dev

JSchException: Algorithm negotiation fail diffie-hellman-group14-sha1

From Dev

JSCH: No such file error

From Dev

SharpSSH jsch Algorithm negotiation fail

From Dev

JSch Algorithm negotiation fail

From Dev

com.jcraft.jsch.JSchException: verify: false

From Dev

Permission error when getting file for use with JSch

From Dev

com.jcraft.jsch.JSchException: channel is not opened when opening a channel in jsch

From Dev

Office365 auth fail: Application with identifier XXX was not found in the directory YYY.onmicrosoft.com

From Dev

JSch algorithm negotiation fail with OSX El Capitan

From Dev

Folder does not exists when changing directory using jcraft.jsch

From Dev

Query fail with no error

From Dev

sendmail smtp auth simple,why fail auth?

From Dev

Jsch connection with private key fails with com.jcraft.jsch.JSchException: Auth fail error

From Dev

JSCH: No such file error

From Dev

com.jcraft.jsch.JSchException: failed to send sftp request

From Dev

will com.jcraft.jsch.ChannelSftp.get(String src,String dst) over rides the existing file?

From Dev

Office365 auth fail: Application with identifier XXX was not found in the directory YYY.onmicrosoft.com

From Dev

Connection issue using SFTP and JSch: com.jcraft.jsch.JSchException

From Dev

Fail on cf ic login. Auth error= InvalidToken

From Dev

com.jcraft.jsch.JSchException: java.io.IOException: Pipe closed

From Dev

Google Auth Error - com.google.android.gms.auth.UserRecoverableAuthException: NeedPermission

Related Related

  1. 1

    Testing jsch on gitlab results in invalid privatekey error

  2. 2

    Width="*" in longlistselector giving error "Error HRESULT E_FAIL has been returned from a call to a COM component"

  3. 3

    com.jcraft.jsch.JSchException: Auth fail error

  4. 4

    Laravel Auth::logout() Fail

  5. 5

    SFTP via JSch is throwing error 4: Failure

  6. 6

    com.jcraft.jsch.JSchException: java.net.ConnectException: Connection refused: connect

  7. 7

    Yowsup auth fail whatsapp

  8. 8

    Jsch connection with private key fails with com.jcraft.jsch.JSchException: Auth fail error

  9. 9

    JSchException: Algorithm negotiation fail diffie-hellman-group14-sha1

  10. 10

    JSCH: No such file error

  11. 11

    SharpSSH jsch Algorithm negotiation fail

  12. 12

    JSch Algorithm negotiation fail

  13. 13

    com.jcraft.jsch.JSchException: verify: false

  14. 14

    Permission error when getting file for use with JSch

  15. 15

    com.jcraft.jsch.JSchException: channel is not opened when opening a channel in jsch

  16. 16

    Office365 auth fail: Application with identifier XXX was not found in the directory YYY.onmicrosoft.com

  17. 17

    JSch algorithm negotiation fail with OSX El Capitan

  18. 18

    Folder does not exists when changing directory using jcraft.jsch

  19. 19

    Query fail with no error

  20. 20

    sendmail smtp auth simple,why fail auth?

  21. 21

    Jsch connection with private key fails with com.jcraft.jsch.JSchException: Auth fail error

  22. 22

    JSCH: No such file error

  23. 23

    com.jcraft.jsch.JSchException: failed to send sftp request

  24. 24

    will com.jcraft.jsch.ChannelSftp.get(String src,String dst) over rides the existing file?

  25. 25

    Office365 auth fail: Application with identifier XXX was not found in the directory YYY.onmicrosoft.com

  26. 26

    Connection issue using SFTP and JSch: com.jcraft.jsch.JSchException

  27. 27

    Fail on cf ic login. Auth error= InvalidToken

  28. 28

    com.jcraft.jsch.JSchException: java.io.IOException: Pipe closed

  29. 29

    Google Auth Error - com.google.android.gms.auth.UserRecoverableAuthException: NeedPermission

HotTag

Archive