DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Building a High-Throughput Distributed Sequence Generator Using the Hi-Lo Algorithm
  • The Quantum Computing Mirage: What Three Years of Broken Promises Have Taught Me
  • Discover Hidden Patterns with Intelligent K-Means Clustering
  • Mastering Approximate Top K: Choosing Optimal Count-Min Sketch Parameters

Trending

  • Claude Code Superpowers: The 5-Tool Stack That Ends Limits and Context Amnesia
  • Delta Lake UniForm to Snowflake: Cross-Platform Table Access Without a Second Copy
  • Google Cloud KMS vs. AWS KMS: Java Encryption Guide
  • GenAI Security Gateway: An End-to-End Architecture

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Data Engineering
  3. AI/ML
  4. How to Solve Mule SFTP Connector Algorithm Negotiation Fail Exception

How to Solve Mule SFTP Connector Algorithm Negotiation Fail Exception

This quick tutorial will show you how to resolve issues with the Mule SFTP connector connecting to remote file locations.

By 
Rajiv Mishra
·
Dec. 29, 17 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
24.9K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

This article is the resolution of the Mule SFTP connector when connecting to remote file locations.

The configurations details are below:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:sftp="http://www.mulesoft.org/schema/mule/sftp" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
       xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd">
       <sftp:connector name="SFTP" validateConnections="true" doc:name="SFTP" />
       <flow name="sftpflow">
             <sftp:inbound-endpoint connector-ref="SFTP" host="host_ip" port="22" path="File Loactions " user="USERNAME" password="PASSWORD"
                    responseTimeout="10000" doc:name="SFTP" >
            <reconnect count="3"/>
        </sftp:inbound-endpoint>
             <logger message="Able to read file :- #[payload]" level="INFO" doc:name="Logger" />
       </flow>
</mule>


The exception will be:

com.jcraft.jsch.JSchException: Algorithm negotiation fail
       at com.jcraft.jsch.Session.receive_kexinit(Session.java:583) ~[jsch-0.1.51.jar:?]


The SFTP connector for Mule has the in-built support jsch-0.1.51.jar. So, while connecting to secure file locations through the SFTP connector, the com.jcraft.jsch.JSchException: Algorithm negotiation fail exception is thrown.

In the JSch.class for jsch-0.1.51.jar, for the KEY -->"kex," it does not have the value "diffie-hellman-group-exchange-sha256" for connecting to the remote location securely. The sha256 exchange pattern is required, which is there in the jsch-0.1.54.jar file. But for 3.6.2/3.7.1 and 3.8.1 runtime versions, the in-built third party jsch-0.1.51.jar has been used.

The Workaround

 Override the KEY "kex" and add the value diffie-hellman-group-exchange-sha256.

The following block should be added in the Static block:

configuration.put("kex", "diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256");

JSch.setConfig(configuration);

public class JSchKeyConfig {
 static {
  Properties configuration = new Properties();
  configuration.put("kex", "diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256");
  JSch.setConfig(configuration);
 }


Inject the JSchKeyConfig through Spring beans. 

Connector (mathematics) Algorithm

Opinions expressed by DZone contributors are their own.

Related

  • Building a High-Throughput Distributed Sequence Generator Using the Hi-Lo Algorithm
  • The Quantum Computing Mirage: What Three Years of Broken Promises Have Taught Me
  • Discover Hidden Patterns with Intelligent K-Means Clustering
  • Mastering Approximate Top K: Choosing Optimal Count-Min Sketch Parameters

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook