Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-5242

camel-jsch (a.k.a camel-scp) component doesn't support public-private key based authentication

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.9.2
    • 2.9.3, 2.10.0
    • camel-jsch
    • None
    • Unknown

    Description

      Camel uses JSCH (http://www.jcraft.com/jsch/) library to support both SCP and SFTP. This library supports public-private key based authentication using com.jcraft.jsch.JSch.addIdentity method. However looks like Camel only supports this feature for SFTP component (http://camel.apache.org/ftp2.html) and there is no support for SCP (http://camel.apache.org/jsch.html)!

      Taking into account the fact that org.apache.camel.component.jsch.ScpConfiguration (version 2.9.2) already has two attributes (privateKeyFile and privateKeyFilePassphrase) for collecting the related data, I think the change for this improvement should be something like :

      org.apache.camel.component.jsch.ScpOperations.createSession(ScpConfiguration config) {
      ObjectHelper.notNull(config, "ScpConfiguration");
      try {
      final JSch jsch = new JSch();
      // get from configuration
      if (isNotEmpty(config.getCiphers())) {
      LOG.debug("Using ciphers: {}", config.getCiphers());
      Hashtable<String, String> ciphers = new Hashtable<String, String>();
      ciphers.put("cipher.s2c", config.getCiphers());
      ciphers.put("cipher.c2s", config.getCiphers());
      JSch.setConfig(ciphers);
      }
      //New code to handle public-private key based authentication
      if (isNotEmpty(config.getPrivateKeyFile())) {
      LOG.debug("Using private keyfile: {}", config.getPrivateKeyFile());
      if (isNotEmpty(config.getPrivateKeyFilePassphrase()))

      { jsch.addIdentity(config.getPrivateKeyFile(), config.getPrivateKeyFilePassphrase()); }

      else

      { jsch.addIdentity(config.getPrivateKeyFile()); }

      }

      ...

      Attachments

        Activity

          People

            hadrian Hadrian Zbarcea
            mohammadwrk Mohammad Wrk
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: