Hi Team,

I am looking for help in public key authentication implementation and
facing the issue while connecting to the SFTP server using private key(in
bytes).

*Issue Scenario :*

When I am passing the privatekeyFile to the endpoint url then it is working
fine but when I am trying to pass the privateKey in bytes array then
getting exception as *Invalid private key.*

*code snapshot: *

System.out.println("\n SFTP Connection Demo \n");

String
PRIVTE_KEY_PATH="C:\\Users\\hp\\Downloads\\RebexTinySftpServerBin-1.0.5\\data\\KeyPair\\private_Key01.ppk";
//uri = "sftp://[email protected]:22//BAM?privateKeyFile=
"+PRIVTE_KEY_PATH;

byte[] fileBytes = SFTPDemo.fromFile(PRIVTE_KEY_PATH);
System.out.println("\nFile bytes len : " + fileBytes.length);

uri = "sftp://Nilesh01@192.
***.**.**:22//BAM?maximumReconnectAttempts=2&privateKey="+fileBytes;

try {
DefaultCamelContext camelContext = new DefaultCamelContext();
ProducerTemplate producer = camelContext.createProducerTemplate();
Object obj=new String("123");
System.out.println(uri);
* producer.sendBodyAndHeaders(uri,obj,null);*

   } catch (CamelExecutionException e) {
       System.out.println("\nException Nilesh :"+ e +"\n" +
e.getCause().getCause());

   }catch(Exception e) {
    System.out.println("\nException Nilesh :"+ e);
   }

Thank you for your help in advance...!!!

Could you please assist me how to pass privateKey parameter in the endpoint
uri.

Reply via email to