Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.9.2
-
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()))
else
{ jsch.addIdentity(config.getPrivateKeyFile()); }}
...