Hi,
I try to connect to a SFTP-Server with a AES-256-CBC private key using a 
passphrase.
I created the following method for testing purposes, so it doesn't do anything 
useful but shows the problem.
    public void sftpConnect()
    {

        Session session = null;
        try
        {
            System.out.println("privateKey: " + privateKey);
            System.out.println("passphrase: " + passphrase);
            System.out.println("host: " + username + "@" + host + ":" + port);

            byte[] passphraseBytes = null;
            if (passphrase != null)
            {
                passphraseBytes = passphrase.getBytes("ISO-8859-1");
            }

            JSch jsch = new JSch();

            jsch.addIdentity(username, privateKey.getBytes("ISO-8859-1"), null, 
passphraseBytes);
            session = jsch.getSession(username, host, port);
            session.setConfig("StrictHostKeyChecking", "no");

            // session.setConfig("cipher.s2c", "aes256-cbc");
            // session.setConfig("cipher.c2s", "aes256-cbc");
            // session.setConfig("CheckCiphers", "aes256-cbc");

            session.connect();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

        if (session != null)
        {
            session.disconnect();
        }

    }
If I run this, I get (things between [] are manually replaced for this mail 
only):
privateKey: -----BEGIN DSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,76575591709273D449EAFE15513FBCEF

[...key in base64 encoding...]
-----END DSA PRIVATE KEY-----
passphrase: [passphrase]
host: [EMAIL PROTECTED]:22
com.jcraft.jsch.JSchException: Auth fail
        at com.jcraft.jsch.Session.connect(Session.java:451)
        at com.jcraft.jsch.Session.connect(Session.java:149)
        at 
ch.post.it.bln.server.extension.adapter.ezag.JschAuthTest.testJsch(JschAuthTest.java:120)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at 
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
        at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)

        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
The key/passphrase is working with that [EMAIL PROTECTED]:port, I've tested 
that with OpenSSH's ssh-client.

I'm using Jsch in version 0.38 and can't easily update to the latest and 
greatest.

Any ideas? Every hint is welcome!

Thanks,
Sandro


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
JSch-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to