Announcement Announcement Module
Collapse
No announcement yet.
DefaultSftpSessionFactory not working in 2.0.6 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • DefaultSftpSessionFactory not working in 2.0.6

    Hello, I am trying to open a sftp session using Spring Integration version 2.0.6. This is as described in the jira issue -

    https://jira.springsource.org/browse...s:all-tabpanel

    Per the fix versions label in JIRA the issue should've been fixed in both 2.0.6 and 2.1.1. I was able to get the code below to work in 2.1.1 but not in 2.0.6.

    Here's the simple sample code -
    Code:
            DefaultSftpSessionFactory sftpSessionFactory = new DefaultSftpSessionFactory();
            sftpSessionFactory.setUser("test-user");
            sftpSessionFactory.setPassword("test-password");
            sftpSessionFactory.setHost("localhost");
            sftpSessionFactory.getSession();
    Here's the Log and the exception -
    Code:
    05-31-2012@15:26:57.597 INFO  [main] (JschLogger.java:52)     - Connecting to localhost port 22
    05-31-2012@15:26:57.602 INFO  [main] (JschLogger.java:52)     - Connection established
    05-31-2012@15:26:57.616 INFO  [main] (JschLogger.java:52)     - Remote version string: SSH-2.0-OpenSSH_5.6
    05-31-2012@15:26:57.616 INFO  [main] (JschLogger.java:52)     - Local version string: SSH-2.0-JSCH-0.1.42
    05-31-2012@15:26:57.617 INFO  [main] (JschLogger.java:52)     - CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
    05-31-2012@15:26:57.768 INFO  [main] (JschLogger.java:52)     - SSH_MSG_KEXINIT sent
    05-31-2012@15:26:57.768 INFO  [main] (JschLogger.java:52)     - SSH_MSG_KEXINIT received
    05-31-2012@15:26:57.769 INFO  [main] (JschLogger.java:52)     - kex: server->client aes128-ctr hmac-md5 none
    05-31-2012@15:26:57.770 INFO  [main] (JschLogger.java:52)     - kex: client->server aes128-ctr hmac-md5 none
    05-31-2012@15:26:57.779 INFO  [main] (JschLogger.java:52)     - SSH_MSG_KEXDH_INIT sent
    05-31-2012@15:26:57.779 INFO  [main] (JschLogger.java:52)     - expecting SSH_MSG_KEXDH_REPLY
    05-31-2012@15:26:57.792 INFO  [main] (JschLogger.java:52)     - ssh_rsa_verify: signature true
    05-31-2012@15:26:57.795 WARN  [main] (JschLogger.java:55)     - Permanently added 'localhost' (RSA) to the list of known hosts.
    05-31-2012@15:26:57.795 INFO  [main] (JschLogger.java:52)     - SSH_MSG_NEWKEYS sent
    05-31-2012@15:26:57.795 INFO  [main] (JschLogger.java:52)     - SSH_MSG_NEWKEYS received
    05-31-2012@15:26:57.798 INFO  [main] (JschLogger.java:52)     - SSH_MSG_SERVICE_REQUEST sent
    05-31-2012@15:26:57.799 INFO  [main] (JschLogger.java:52)     - SSH_MSG_SERVICE_ACCEPT received
    05-31-2012@15:26:57.801 INFO  [main] (JschLogger.java:52)     - Authentications that can continue: publickey,keyboard-interactive,password
    05-31-2012@15:26:57.801 INFO  [main] (JschLogger.java:52)     - Next authentication method: publickey
    05-31-2012@15:26:57.802 INFO  [main] (JschLogger.java:52)     - Authentications that can continue: keyboard-interactive,password
    05-31-2012@15:26:57.802 INFO  [main] (JschLogger.java:52)     - Next authentication method: keyboard-interactive
    05-31-2012@15:26:57.811 INFO  [main] (JschLogger.java:52)     - Disconnecting from localhost port 22
    Code:
    java.lang.IllegalStateException: failed to create SFTP Session
    	at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:158)
    	at org.springframework.integration.samples.sftp.SftpOutboundTransferSample.testSftpConnection(SftpOutboundTransferSample.java:61)
    	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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    Caused by: java.lang.IllegalStateException: failed to connect
    	at org.springframework.integration.sftp.session.SftpSession.connect(SftpSession.java:175)
    	at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:154)
    	... 24 more
    Caused by: 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.springframework.integration.sftp.session.SftpSession.connect(SftpSession.java:167)
    	... 25 more
    Can someone please let me know if this is indeed fixed in 2.0.6? If so, am I missing something?

    I really dont want to go with the alternate route of upgrading the whole project to 2.1.1 (Which from my tests require spring core upgrade to 3.0.7 as well).

    Thanks and regards,
    Shyam

  • #2
    I'd say it would be nice if you can try 2.1.1 (just for the sake of trying) but the issue indeed was backported and looking at your trace it seems to me you are having some other issue. The message you showing is:
    Code:
    Caused by: com.jcraft.jsch.JSchException: Auth cancel
    I am not sure where its coming from and why and what is canceling your authentication attempt.
    Can you SSH to the host with the same credentials?
    Can you provide more details as to how you access the host outside SI?

    Comment


    • #3
      Hi Oleg, thank you for your reply. I can ssh to the host with same credentials via terminal and I also tested the same code successfully on 2.1.1.

      The code eventually will be used via int-sftp:outbound-channel-adapter by defining org.springframework.integration.sftp.session.Defau ltSftpSessionFactory as spring bean. Ever since I've came across this error I am trying to test this very basic connectivity problem, using the code I've posted earlier.

      Comment


      • #4
        2.1.1 uses jsch 0.1.45; 2.0.6 uses 0.1.42.

        I was able to reproduce your problem with 2.0.6; upgrading jsch to 0.1.45 fixes the problem; add...

        Code:
        		<dependency>
        			<groupId>com.jcraft</groupId>
        			<artifactId>jsch</artifactId>
        			<version>0.1.45</version>
        		</dependency>
        ...to your pom.

        Comment


        • #5
          DefaultSftpSessionFactory not working in 2.0.6 [Solved]

          That seems to have done the trick. Its working now.

          Thank you Oleg and Gary for quick replies.

          Shyam
          Last edited by bn.shyam; Jun 1st, 2012, 08:29 AM.

          Comment

          Working...
          X