Search code examples
mule-studio

How do I stop the Mule SFTP Connector from prompting for Kerberos Username?


I am attempting to upload a file using SFTP. I have an identity file set up and referenced correctly. When my flow gets to the SFTP it pauses execution and prompts for Kerberos username and Kerberos password. I do not need to enter anything for these and just pressing enter will allow execution to continue and will correctly upload my file. Doing research on this, it appears to be a Java1.7 bug and is referenced here: https://www.mulesoft.org/jira/browse/MULE-6864. In that Jira task they mention "Setting "PreferredAuthentications" property to "publickey,password,keyboard-interactive" in the SftpClient solves the problem." So where do I set this property? It isn't part of the connector. I tried adding it as an attribute directly in the XML but that didn't work either.

I am developing in Anypoint Studio July 2014, deploying to Mule 3.5.0EE.


Solution

  • The answer was in the same Jira entry listed above. I needed to create a java class to do the configuration. Just add the following class to your project:

    package com.mycompany.utils;
    
    import org.apache.log4j.Logger;
    import org.mule.api.MuleEventContext;
    import org.mule.api.lifecycle.Callable;
    
    import com.jcraft.jsch.JSch;
    
    
    
    public class SftpFix implements Callable{
        private static final Logger LOG = Logger.getLogger("com.mycompany");
        static
        { // A bug fix for MULE-6864, where Java 7 causes an issue SSH'ing to a Linux box with Kerberos enabled. 
            LOG.info("Applying patch to JSch for MULE-6864"); 
            JSch.setConfig("PreferredAuthentications", "publickey,password,keyboard-interactive"); 
        } 
    
        @Override
        public Object onCall(MuleEventContext eventContext){
            return eventContext.getMessage().getPayload();
        }
    
    }